A TCP proxy method, device and storage medium

By receiving packets in the proxy device and switching to the target state, maintaining a simplified state machine and window length control, the problem of insufficient processing and storage capacity of the proxy device is solved, realizing the functionality and performance overhead of TCP proxy.

CN119496810BActive Publication Date: 2026-02-13DATANG MOBILE COMM EQUIP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311048505.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-18
Publication Date
2026-02-13
Estimated Expiration
2043-08-18

AI Technical Summary

Technical Problem

The processing and storage capabilities of proxy devices are limited, making it impossible to support full TCP proxy functionality and performance overhead.

Method used

After receiving a message, the agent device determines the target state based on the current state and switches to that state. It maintains a simplified state machine and reduces processing and storage requirements by adjusting the window length and handling the timeout queue.

Benefits of technology

It simplifies the maintenance complexity of the TCP proxy state machine and reduces the processing and storage requirements of the proxy device, enabling it to perform TCP proxy functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119496810B_ABST
    Figure CN119496810B_ABST
Patent Text Reader

Abstract

The application provides a TCP proxy method, device and storage medium, and relates to the technical field of communication. In the method, a proxy device receives a first message sent by a first device, the first device is a client device or a server device; a target state is determined according to the first message and a current state of the proxy device, the target state is any one of the following states: a link establishment state, a data transmission state, a first link deletion state, a second link deletion state and a connectionless state; and the current state is switched to the target state. The proxy device connects a CT segment and a TS segment, and maintains a set of simplified state machines together, which greatly reduces the maintenance complexity of a TCP proxy state machine, and further reduces the requirement for the processing capacity of the proxy device.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of communication, and in particular to a TCP proxy method and device and storage medium. BACKGROUND

[0002] A Transmission Control Protocol (TCP) proxy device divides a TCP link into two segments, a link between the proxy device and a server (referred to as a TS segment) and a link between a client and the proxy device (referred to as a CT segment). For the server, the proxy device needs to implement the function of the client, and for the client, the proxy device needs to implement the function of the server, which is equivalent to developing a complete TCP protocol stack, and has a high requirement for the processing resources and storage resources of the proxy device.

[0003] When the processing capability and storage capability of the proxy device (such as a base station) are limited, the limited processing capability and storage capability cannot support the proxy device to complete the function and performance overhead of TCP proxy. SUMMARY

[0004] The present application provides a TCP proxy method, device and storage medium, which solves the technical problem that the limited processing capability and storage capability of the proxy device cannot support the proxy device to complete the function and performance overhead of TCP proxy.

[0005] In a first aspect, an embodiment of the present application provides a TCP proxy method applied to a proxy device, and the method comprises the following steps.

[0006] receiving a first message sent by a first device, the first device being a client device or a server device;

[0007] determining a target state according to the first message and a current state of the proxy device, the target state being any one of a link establishment state, a data transmission state, a first link deletion state, a second link deletion state and a connectionless state;

[0008] switching from the current state to the target state.

[0009] In an embodiment, determining the target state according to the first message and the current state of the proxy device comprises the following steps.

[0010] if the first message is a synchronization message and the current state is the connectionless state, determining that the target state is the link establishment state; or

[0011] if the first message is a synchronization confirmation message and the current state is the link establishment state, determining that the target state is the data transmission state; or

[0012] If the first message is a normal close connection message sent by the server device, and the current state is the data transmission state, then the target state is determined to be the first chain deletion state; or,

[0013] If the first message is an abnormal close connection message sent by the server device, and the current state is the data transmission state, then the target state is determined to be the second chain deletion state; or,

[0014] If the first message is an abnormal close connection message sent by the client device, and the current state is the data transmission state, then the target state is determined to be the no connection state.

[0015] In an embodiment, when the target state is the first chain deletion state or the second chain deletion state, the method further comprises:

[0016] sending data in a TCP proxy cache to the client device until the TCP proxy cache is emptied;

[0017] deleting a TCP link and switching to the no connection state.

[0018] In an embodiment, the method further comprises:

[0019] sending a second message to the server device, the second message comprising a first window length, the first window length satisfying the following formula:

[0020] first window length = min(second window length, theoretical proxy maximum window length)

[0021] wherein the first window length indicates a maximum data amount of a first data packet, the first data packet being a data packet sent by the server device to the proxy device, the second window length indicates a theoretical maximum data amount of a second data packet, the second data packet being a data packet sent by the proxy device to the client device, and the theoretical proxy maximum window length indicates a theoretical maximum data amount of the first data packet.

[0022] In an embodiment, the method further comprises:

[0023] sending a third message to the server device, the third message comprising a third window length, the third window length indicating a data amount of the first data packet;

[0024] wherein the third window length satisfies the following formula:

[0025] third window length = fourth window length - proxy cache data amount - window reduction amount

[0026] The fourth window length indicates a data amount size of the second data packet, the proxy cache data amount is an amount of data in a TCP proxy cache of the proxy device, and the window reduction amount is a constant.

[0027] In an embodiment, the window reduction amount is a difference between the second window length and the first window length.

[0028] In an embodiment, the method further comprises:

[0029] determining a timeout queue corresponding to each time slot in a frame period, the timeout queue comprising a plurality of timeout events;

[0030] determining a scanning period;

[0031] processing the timeout events in the plurality of timeout queues corresponding to the scanning period.

[0032] In an embodiment, determining a timeout queue corresponding to each time slot in a frame period comprises:

[0033] for any one timer, determining a first half frame number and a first time slot number corresponding to a starting time of the timer;

[0034] determining a second half frame number and a second time slot number according to the first half frame number, the first time slot number, and a timing duration of the timer;

[0035] adding the timeout event corresponding to the timer to a timeout queue corresponding to the second half frame number and the second time slot number.

[0036] In a second aspect, an embodiment of the present application provides a TCP proxy device applied to a proxy device, the device comprising a memory, a transceiver, and a processor,

[0037] the memory is configured to store a computer program; the transceiver is configured to transceive data under control of the processor; and the processor is configured to read the computer program in the memory and perform the following operations:

[0038] receiving a first packet sent by a first device, the first device being a client device or a server device;

[0039] determining a target state according to the first packet and a current state of the proxy device, the target state being any one of a link establishment state, a data transmission state, a first link deletion state, a second link deletion state, and a connectionless state;

[0040] switching from the current state to the target state.

[0041] In an embodiment, the processor is specifically configured to perform the following operations:

[0042] if the first message is a synchronization message and the current state is the connectionless state, determining that the target state is the connection establishment state; or

[0043] if the first message is a synchronization acknowledgement message and the current state is the connection establishment state, determining that the target state is the data transmission state; or

[0044] if the first message is a normal close connection message sent by the server device and the current state is the data transmission state, determining that the target state is the first connection deletion state; or

[0045] if the first message is an abnormal close connection message sent by the server device and the current state is the data transmission state, determining that the target state is the second connection deletion state; or

[0046] if the first message is an abnormal close connection message sent by the client device and the current state is the data transmission state, determining that the target state is the connectionless state.

[0047] In an embodiment, when the target state is the first connection deletion state or the second connection deletion state, the processor is further configured to perform the following operation:

[0048] sending data in a TCP proxy cache to the client device until the TCP proxy cache is emptied;

[0049] deleting a TCP link and switching to the connectionless state.

[0050] In an embodiment, the processor is further configured to perform the following operation:

[0051] sending a second message to the server device, the second message comprising a first window length, the first window length satisfying the following formula:

[0052] first window length = min(second window length, theoretical proxy maximum window length)

[0053] wherein the first window length indicates a maximum data amount of a first data packet, the first data packet being a data packet sent by the server device to the proxy device, the second window length indicating a theoretical maximum data amount of a second data packet, the second data packet being a data packet sent by the proxy device to the client device, and the theoretical proxy maximum window length indicating a theoretical maximum data amount of the first data packet.

[0054] In an embodiment, the processor is further configured to perform the following operation:

[0055] sending a third packet to the server device, the third packet comprising a third window length, the third window length indicating a data size of the first data packet;

[0056] wherein the third window length satisfies the following formula:

[0057] the third window length = the fourth window length - proxy cache data size - window shrink size

[0058] the fourth window length indicating a data size of the second data packet, the proxy cache data size being a data size in a TCP proxy cache of the proxy device, and the window shrink size being a constant.

[0059] In an implementation, the window shrink size is a difference between the second window length and the first window length.

[0060] In an implementation, the processor is further configured to perform the following operation:

[0061] determining a timeout queue corresponding to each time slot in a frame period, the timeout queue comprising a plurality of timeout events;

[0062] determining a scanning period;

[0063] processing the timeout events in the plurality of timeout queues corresponding to the scanning period.

[0064] In an implementation, the processor is specifically configured to perform the following operation:

[0065] for any one timer, determining a first half frame number and a first time slot number corresponding to a starting time of the timer;

[0066] determining a second half frame number and a second time slot number according to the first half frame number, the first time slot number, and a timing duration of the timer;

[0067] adding a timeout event corresponding to the timer to a timeout queue corresponding to the second half frame number and the second time slot number.

[0068] In a third aspect, an embodiment of the present application provides a TCP proxy device applied to a proxy device, the device comprising:

[0069] a receiving unit configured to receive a first packet sent by a first device, the first device being a client device or a server device;

[0070] a first determining unit configured to determine a target state according to the first packet and a current state of the proxy device, the target state being any one of the following states: a state of building a connection, a data transmission state, a first state of deleting a connection, a second state of deleting a connection, and a state of no connection;

[0071] A switching unit is configured to switch from the current state to the target state.

[0072] receiving a first packet sent by a first device, the first device being a client device or a server device;

[0073] determining a target state according to the first packet and a current state of the proxy device, the target state being any one of a link establishment state, a data transmission state, a first link deletion state, a second link deletion state, and a connectionless state;

[0074] switching from the current state to the target state.

[0075] In an embodiment, the first determining unit is specifically configured to:

[0076] if the first packet is a synchronization packet and the current state is the connectionless state, determining that the target state is the link establishment state; or

[0077] if the first packet is a synchronization acknowledgement packet and the current state is the link establishment state, determining that the target state is the data transmission state; or

[0078] if the first packet is a normal close connection packet sent by the server device and the current state is the data transmission state, determining that the target state is the first link deletion state; or

[0079] if the first packet is an abnormal close connection packet sent by the server device and the current state is the data transmission state, determining that the target state is the second link deletion state; or

[0080] if the first packet is an abnormal close connection packet sent by the client device and the current state is the data transmission state, determining that the target state is the connectionless state.

[0081] In an embodiment, when the target state is the first link deletion state or the second link deletion state, the apparatus further comprises:

[0082] a first sending unit configured to send data in a TCP proxy cache to the client device until the TCP proxy cache is emptied;

[0083] a deletion unit configured to delete a TCP link and switch to the connectionless state.

[0084] In an embodiment, the apparatus further comprises:

[0085] The second sending unit is configured to send a second packet to the server device, where the second packet comprises a first window length, and the first window length satisfies the following formula:

[0086] The first window length = min (the second window length, the theoretical maximum window length of the proxy)

[0087] The first window length indicates a maximum data amount of a first data packet, the first data packet is a data packet sent by the server device to the proxy device, the second window length indicates a theoretical maximum data amount of a second data packet, the second data packet is a data packet sent by the proxy device to the client device, and the theoretical maximum window length of the proxy indicates a theoretical maximum data amount of the first data packet.

[0088] In an embodiment, the apparatus further comprises:

[0089] The third sending unit is configured to send a third packet to the server device, where the third packet comprises a third window length, and the third window length indicates a data amount of the first data packet.

[0090] The third window length satisfies the following formula:

[0091] The third window length = the fourth window length - the proxy cache data amount - the window reduction amount

[0092] The fourth window length indicates a data amount of the second data packet, the proxy cache data amount is a data amount in a TCP proxy cache of the proxy device, and the window reduction amount is a constant.

[0093] In an embodiment, the window reduction amount is a difference between the second window length and the first window length.

[0094] In an embodiment, the apparatus further comprises:

[0095] The second determining unit is configured to determine a timeout queue corresponding to each time slot in a frame period, and the timeout queue comprises a plurality of timeout events.

[0096] The third determining unit is configured to determine a scanning period.

[0097] The processing unit is configured to process the timeout events in the plurality of timeout queues corresponding to the scanning period.

[0098] In an embodiment, the second determining unit is specifically configured to:

[0099] For any one timer, determine a first half frame number and a first time slot number corresponding to a starting moment of the timer.

[0100] determine a second half frame number and a second time slot number according to the first half frame number, the first time slot number and a timing duration of the timer;

[0101] add the timeout event corresponding to the timer into a timeout queue corresponding to the second half frame number and the second time slot number.

[0102] In a fourth aspect, an embodiment of the present application provides a processor readable storage medium, which stores a computer program, and the computer program is used to make the processor execute the method in the first aspect.

[0103] The application provides a TCP proxy method, device and storage medium. In the method, a proxy device receives a first packet sent by a first device, and the first device is a client device or a server device. According to the first packet and a current state of the proxy device, a target state is determined, and the target state is any one of the following states: a link establishment state, a data transmission state, a first link deletion state, a second link deletion state and a connectionless state. The proxy device switches from the current state to the target state. The proxy device connects a CT segment and a TS segment, and maintains a set of simplified state machines together, which greatly reduces the maintenance complexity of a TCP proxy state machine, and further reduces the requirement on the processing capacity of the proxy device.

[0104] It should be understood that the content described in the foregoing summary section is not intended to define key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS

[0105] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0106] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present application;

[0107] Figure 2 A flowchart of a TCP link establishment process in the related art;

[0108] Figure 3 A flowchart of a TCP link closure process in the related art;

[0109] Figure 4 A flowchart of a TCP proxy method provided by an embodiment of the present application;

[0110] Figure 5A flowchart of a TCP link establishment provided by an embodiment of the present application is shown in FIG. 1.

[0111] Figure 6 A flowchart of a TCP link close provided by an embodiment of the present application is shown in FIG. 2.

[0112] Figure 7 Another flowchart of a TCP link close provided by an embodiment of the present application is shown in FIG. 3.

[0113] Figure 8 A state transition diagram of a TCP proxy provided by an embodiment of the present application is shown in FIG. 4.

[0114] Figure 9 A flowchart of another TCP proxy method provided by an embodiment of the present application is shown in FIG. 5.

[0115] Figure 10 A relationship diagram between various window lengths when a link is being established provided by an embodiment of the present application is shown in FIG. 6.

[0116] Figure 11 A relationship diagram between various window lengths during data transmission provided by an embodiment of the present application is shown in FIG. 7.

[0117] Figure 12 A flowchart of another TCP proxy method provided by an embodiment of the present application is shown in FIG. 8.

[0118] Figure 13 A diagram of a timeout queue in a frame period provided by an embodiment of the present application is shown in FIG. 9.

[0119] Figure 14 A structural diagram of a TCP proxy device provided by an embodiment of the present application is shown in FIG. 10.

[0120] Figure 15 Another structural diagram of a TCP proxy device provided by an embodiment of the present application is shown in FIG. 11. DETAILED DESCRIPTION

[0121] In the embodiments of the present application, the term "and / or" describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. The character " / " generally represents an "or" relationship between the associated objects before and after it.

[0122] In the embodiments of the present application, the term "a plurality of" means two or more, and other quantifiers are similar.

[0123] The description of "first", "second" and the like appearing in the embodiments of the present application is only for indicating and distinguishing the description objects, and does not have order, and does not represent the special limitation of the number of the objects in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application. For example, the first data packet is a data packet sent by the server device to the proxy device, and the second data packet is a data packet sent by the proxy device to the client device. The description of "first", "second" and the like is only for distinguishing different data packets, and does not represent the difference of the size, priority or importance of the two data packets.

[0124] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, and not all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0125] The embodiments of the present application provide a TCP proxy method and device, to simplify the TCP proxy, so that the proxy device with limited processing capacity and storage capacity can also complete the function and performance overhead of the TCP proxy.

[0126] The method and the device are based on the same application concept. Since the principles of the method and the device for solving problems are similar, the implementation of the device and the method can be referred to each other, and the repeated parts will not be described again.

[0127] The technical solutions provided in this application can be applied to various systems, especially 5G systems. For example, applicable systems include Global System for Mobile Communication (GSM), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA) General Packet Radio Service (GPRS), Long Term Evolution (LTE), LTE Frequency Division Duplex (FDD), LTE Time Division Duplex (TDD), Long Term Evolution Advanced (LTE-A), Universal Mobile Telecommunication System (UMTS), Worldwide Interoperability for Microwave Access (WiMAX), and 5G New Radio (NR). All of these systems include terminal equipment and network equipment. The system may also include a core network component, such as the Evolved Packet System (EPS) or the 5G system (5GS).

[0128] The following is combined with Figure 1 The application scenarios of this application are described. Figure 1 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application.

[0129] like Figure 1 As shown, the system includes a client device 101, a proxy device 102, and a server device 103. The client device 101 and server device 103 can communicate with the proxy device 102. The server device 103 can send downlink TCP packets to the client device 101 through the proxy device 102. After receiving the downlink TCP packets, the client device 101 can send an uplink TCP acknowledgment (ACK) message to the server device 103 through the proxy device 102.

[0130] The proxy device can be a base station, which can include multiple cells serving terminals. The base station can also be referred to as an access point, or can be a device in an access network that communicates with wireless terminal devices over an air interface through one or more sectors, or other names, depending on the specific application scenario.

[0131] The proxy device divides the TCP link into two segments: a TS segment and a CT segment. For the server, the proxy device needs to implement the client function, and for the client, the proxy device needs to implement the server function, which is equivalent to developing a complete TCP protocol stack, and has a high requirement on the processing resources and storage resources of the proxy device.

[0132] Next, the complexity of the existing TCP proxy is explained from three aspects of the TCP proxy state machine mechanism, the window length control mechanism, and the timer mechanism.

[0133] Figure 2 A flowchart of a process of establishing a TCP link in the related art is shown. As shown in FIG. 1, first, a client device in a connectionless state (CLOSED) initiates a request for communication and sends a connection request message to a server device, at this time, a synchronize sequence number (SYN) = 1, an initial sequence number (seq) = x of the client device is selected, and the client device enters a SYN-SEND state. Figure 2

[0134] Then, the server device in the connectionless state is passively opened and enters a LISTEN state. After receiving the request in the LISTEN state, the server device sends an acknowledgement message to the client device, in which the SYN and ACK bits are both set to 1, an acknowledge number (ack) = x+1, an initial sequence number seq = y of the server device is selected, and the server device enters a SYN-RECEIVED state.

[0135] Finally, after receiving the acknowledgement message of the server device, the client device sends an acknowledgement message to the server device, in which the ACK is set to 1, the acknowledge number ack = y+1, and the sequence number seq = x+1 of the client device, and the client device enters an ESTABLISHED state. After receiving the acknowledgement message sent by the client device, the server device enters the ESTABLISHED state.

[0136] After the TCP connection is established, the communication parties complete the transmission of data, and it is required to close the TCP connection, at this time, four handshakes are required to close the link. The link closing process can be initiated by the client device or the server device.

[0137] Figure 3 ​This is a schematic diagram illustrating a TCP link closure process in related technologies. For example... Figure 3 As shown, taking the client device actively initiating the connection closure as an example, the client device first sends a connection closure message to the server device and stops sending data. In the connection closure message, FIN=1 and sequence number seq=u, which is equal to the sequence number of the last byte of the previously transmitted data plus 1. At this point, the client device enters the connection closure sent state (FIN-WAIT-1) and waits for confirmation from the server device.

[0138] Then, after receiving the close connection message, the server device sends an acknowledgment message to confirm the close connection. In this message, ACK=1, acknowledgment number ack=u+1, and its own sequence number seq=v. This sequence number is equal to the sequence number of the last byte of the data that the server device has transmitted before plus 1. The server device then enters the close connection received state (CLOSE-WAIT).

[0139] Next, after receiving the confirmation from the server device, the client device enters the closed connection confirmed state (FIN-WAIT-2), waiting for the server device to send a closed connection message. In the closed connection message sent by the server device, FIN=1, the acknowledgment number must be the same as the acknowledgment number sent last time, i.e., ack=u+1, and the sequence number seq=v. The server device then enters the waiting-for-confirmation closed connection state (LAST-ACK), waiting for the client device's confirmation.

[0140] Finally, after receiving the connection close message from the server, the client device must send an acknowledgment. In the acknowledgment segment, ACK = 1, acknowledgment number ack = v + 1, and its own sequence number seq = u + 1. Then, it enters the time-wait connection close state. At this point, the TCP connection is not yet released. The client device must wait for twice the maximum segment lifetime (MSL) set by the timer before entering the connectionless state. The server device then enters the connectionless state after receiving the client device's acknowledgment.

[0141] During the TCP link establishment and TCP connection closing phases, the proxy device needs to maintain a state machine like the client device and a state machine like the server device. Since each state machine includes many states, the states that the TCP proxy needs to maintain are too complex.

[0142] In the window length control mechanism, the proxy device independently controls the window length of the CT segment and the TS segment. Since the TS segment is a wired network, the time delay and packet loss rate are much better than the wireless network of the CT segment. Therefore, the number of messages confirmed by the proxy device of the TS segment is much more than the requirement of the CT segment, which causes the data flow of the proxy device to be seriously accumulated and the memory consumption to be huge.

[0143] In the timer mechanism, the existing method is to use a timer to drive a timing scan of all pending timing events, to determine whether the timer has expired. If the timer has expired, the related timing event processing is performed. The characteristics are that a periodic trigger source is needed to trigger a scan of all pending events, a multi-task execution environment is needed, multi-task access is involved, locking is needed, the business processing flow is frequently interrupted, and task switching and cache miss aggravate, which seriously affect the software performance.

[0144] Based on the problems in the prior art, the present application proposes the following technical concept: simplifying the TCP proxy to reduce the requirements for the processing capability and the storage capability of the proxy device, so that the proxy device with limited processing capability and storage capability can complete the functions and performance overhead of the TCP proxy.

[0145] The TCP proxy method provided by the present application will be described below in combination with specific embodiments.

[0146] Figure 4 A flowchart of a TCP proxy method provided by an embodiment of the present application is shown in FIG. 1. As shown in FIG. 1, the method comprises the following steps. Figure 4

[0147] S401, receiving a first message sent by a first device.

[0148] The execution subject of the embodiment of the present application is a proxy device such as a base station, or a TCP proxy device provided in the proxy device. The TCP proxy device can be implemented by software, or by the combination of software and hardware.

[0149] The first device can be a client device or a server device.

[0150] The first message can be a synchronization message, a synchronization confirmation message, a normal connection closing message and / or an abnormal connection closing message.

[0151] S402, determining a target state according to the first message and the current state of the proxy device, the target state being any one of the following: a connection establishment state, a data transmission state, a first connection deletion state, a second connection deletion state and a connectionless state.

[0152] ​In the TCP link establishment stage, the proxy device only needs to maintain the link establishment state and the data transmission state; in the TCP link closing stage, the proxy device only needs to maintain the first link deletion state and the second link deletion state.

[0153] In a possible implementation, if the first message is a synchronization message and the current state of the proxy device is the connectionless state, the target state is determined to be the link establishment state.

[0154] In the link establishment state, the proxy device can establish the TCP link.

[0155] In a possible implementation, if the first message is a synchronization confirmation message and the current state of the proxy device is the link establishment state, the target state is determined to be the data transmission state.

[0156] In the data transmission state, the proxy device can perform data transmission and reception with the client device and / or the server device.

[0157] In a possible implementation, if the first message is a normal close connection message sent by the server device and the current state of the proxy device is the data transmission state, the target state is determined to be the first link deletion state.

[0158] In the first link deletion state, the proxy device can delete the TCP link.

[0159] In a possible implementation, if the first message is an abnormal close connection message sent by the server device and the current state of the proxy device is the data transmission state, the target state is determined to be the second link deletion state.

[0160] In the second link deletion state, the proxy device can delete the TCP link.

[0161] In a possible implementation, if the first message is an abnormal close connection message sent by the client device and the current state of the proxy device is the data transmission state, the target state is determined to be the connectionless state.

[0162] When the abnormal close connection message sent by the client device is received, the proxy device immediately empties the TCP proxy cache and deletes the TCP link, and switches to the connectionless state.

[0163] S403, switch from the current state to the target state.

[0164] In a possible implementation, when the proxy device switches to the target state, and the target state is the first link deletion state or the second link deletion state, the proxy device sends the data in the TCP proxy cache to the client device until the TCP proxy cache is emptied, and then deletes the TCP link and switches to the connectionless state.

[0165] InFigure 4 In the illustrated embodiment, the proxy device receives a first message sent by a first device, which can be a client device or a server device. Based on the first message and the current state of the proxy device, it determines a target state, which can be any of the following: connection establishment state, data transmission state, first connection deletion state, second connection deletion state, or connectionless state. The proxy device then switches from the current state to the target state. In this embodiment, the proxy device connects the CT segment and the TS segment, jointly maintaining a simplified state machine, greatly reducing the maintenance complexity of the TCP proxy state machine and thus reducing the processing power requirements of the proxy device.

[0166] To facilitate understanding, the following sections will explain the switching of the proxy device's state by referring to the TCP link establishment process and the TCP link closure process.

[0167] Figure 5 This is a schematic diagram illustrating a TCP link establishment process provided in an embodiment of this application. Figure 5 As shown, firstly, the client device in a connectionless state actively requests communication by sending a synchronization message (also known as a connection request message) to the proxy device and entering the synchronization sent state. Upon receiving the synchronization message from the client device, the proxy device in a connectionless state enters the connection establishment state and sends a synchronization message to the server device.

[0168] Then, the server device, which was in a connectionless state, is passively opened and enters a listening state. After receiving a synchronization message in the listening state, it enters a synchronization received state and sends a synchronization acknowledgment message to the proxy device. After receiving the synchronization acknowledgment message from the server device, the proxy device enters a data transmission state and sends a synchronization acknowledgment message to the client device.

[0169] Finally, after receiving the synchronization confirmation message from the proxy device, the client device sends a confirmation message to the proxy device and enters the connection established state; after receiving the confirmation message from the client device, the proxy device sends a confirmation message to the server device, and after receiving the confirmation message from the proxy device, the server device enters the connection established state.

[0170] After the TCP link is established, the proxy device transmits data with the client device and the server device respectively during the data transmission state.

[0171] It should be noted that, Figure 5 The present application only provides a scenario where the client device actively establishes the chain. The embodiments of this application can also be used for scenarios where the server device actively establishes the chain, and even for scenarios where the client device and the server device establish the chain simultaneously.

[0172] Figure 6 This is a schematic diagram illustrating a TCP link closure process provided in an embodiment of this application.Figure 6 As shown, firstly, the client device sends a normal connection close message to the proxy device and stops sending data. At this time, the client device enters the connection close sent state. After receiving the normal connection close message sent by the client device, the proxy device sends a normal connection close message to the server device.

[0173] Then, after receiving the normal connection closure message from the proxy device, the server device sends an acknowledgment message confirming the connection closure and enters the connection closure received state; after receiving the acknowledgment message from the server device, the proxy device sends an acknowledgment message to the client device; after receiving the acknowledgment message, the client device enters the connection closure confirmed state and waits to receive the normal connection closure message.

[0174] Next, the server device sends a normal connection close message and enters the waiting confirmation state for connection closure. After receiving the normal connection close message from the server device, the proxy device enters the first deletion state, caches the normal connection close message, and sends the data in the TCP proxy cache to the client device until the TCP proxy cache is cleared, and then sends the normal connection close message to the client device again.

[0175] Finally, after receiving the normal connection closure message, the client device sends an acknowledgment message to confirm the connection closure, and then enters a delayed connection closure state. After 2MSL, it enters a connectionless state. After receiving the acknowledgment message, the proxy device sends an acknowledgment message to the server device, deletes the TCP link, and enters a connectionless state. After receiving the acknowledgment message, the server device enters a connectionless state.

[0176] Figure 7 This is a schematic diagram illustrating another TCP link closure process provided in an embodiment of this application. For example... Figure 7 As shown, the server device sends an abnormal connection close message to the proxy device, entering a connectionless state. Upon receiving the abnormal connection close message from the server device, the proxy device enters a second deletion state, caches the abnormal connection close message, stops acknowledging subsequent data from the server device, and continues sending data from the TCP proxy cache to the client device until the TCP proxy cache is cleared. Then, it sends another abnormal connection close message to the client device, deletes the TCP link, and enters a connectionless state. The client device enters a connectionless state upon receiving the abnormal connection close message.

[0177] When the abnormal closing is initiated by the client device, the abnormal closing connection message is sent by the client device to the proxy device, and the connection state is entered. The proxy device empties the TCP proxy cache immediately after receiving the abnormal closing connection message sent by the client device, and sends the abnormal closing connection message to the server device, and enters the connection state. The server device enters the connection state immediately after receiving the abnormal closing connection message.

[0178] In the embodiment of the application, the proxy device pulls the CT segment and the TS segment, and a set of simplified state machines are maintained together. The state transition of the proxy device is as shown in the figure, and only involves the transition of a small number of states, thereby reducing the requirement on the processing capacity of the proxy device. Figure 8

[0179] On the basis of any of the above embodiments, the simplification of the window length in the TCP proxy simplification process will be described in detail below. Figure 9

[0180] Figure 9 Another flowchart of a TCP proxy method provided in the embodiment of the application is shown in FIG. 9. As shown in FIG. 9, the method comprises the following steps. Figure 9

[0181] S901, a second message is sent to the server device, and the second message comprises a first window length.

[0182] The second message can be a synchronization message.

[0183] The first window length can indicate the maximum data amount of the first data packet.

[0184] The first data packet is a data packet sent by the server device to the proxy device.

[0185] That is, the first window length indicates the maximum data amount of the data packet that can be received by the proxy device.

[0186] The first window length = min (second window length, theoretical proxy maximum window length)

[0187] The second window length can indicate the theoretical maximum data amount of the second data packet.

[0188] The second data packet is a data packet sent by the proxy device to the client device.

[0189] That is, the second window length indicates the theoretical maximum data amount of the data packet that can be received by the client device.

[0190] The theoretical proxy maximum window length can indicate the theoretical maximum data amount of the first data packet.

[0191] The theoretical TCP proxy maximum window length can be calculated according to the wired side Round Trip Time (RTT) and the service rate. ​​​

[0192] For example, when RTT = 10 ms and the service rate = 2 Gbps, the theoretical maximum TCP proxy window length = 2.5 MB can be calculated.

[0193] S902, send a third message to the server device, the third message comprising a third window length.

[0194] The third message can be an acknowledgement message.

[0195] The third window length can indicate the data amount size of the first data packet.

[0196] That is, the third window length indicates the data amount size of the data packet that the proxy device can still receive.

[0197] The third window length satisfies the following formula:

[0198] Third window length = fourth window length - proxy cache data amount - window shrink amount Formula (1)

[0199] The fourth window length indicates the data amount size of the second data packet, that is, the fourth window length indicates the data amount size of the data packet that the client device can still receive; the proxy cache data amount is the data amount in the TCP proxy cache of the proxy device, and the window shrink amount is a constant.

[0200] The third window length is ensured to be smaller than the fourth window length by the window shrink amount, so as to limit the situation that the proxy device cache is excessively occupied from occurring.

[0201] When the link is established, the proxy cache data amount is 0, the acknowledgement transmission sequence number (TSN) of the client device = the acknowledgement TSN of the proxy device, and the relationship between the various window lengths is as shown in Figure 10 , that is:

[0202] First window length = second window length = fourth window length = third window length - window shrink amount

[0203] During data transmission, the client cache data amount is greater than 0, and the proxy cache data amount is greater than 0, at this time, the acknowledgement TSN of the client device is different from the acknowledgement TSN of the proxy device, and the relationship between the various window lengths and the acknowledgement TSN is as shown in Figure 11 , that is:

[0204] Client cache data amount = acknowledgement TSN of client device - delivery TSN of client device

[0205] Proxy cache data amount = acknowledgement TSN of proxy device - acknowledgement TSN of client device

[0206] Acknowledgement TSN of client device + fourth window length = acknowledgement TSN of proxy device + third window length + window shrink amount

[0207] From the above formula, it can be deduced that:

[0208] Third window length = fourth window length - proxy cache data volume - window shrink volume Formula (1)

[0209] In one possible implementation, the window shrink volume = second window length - first window length.

[0210] The third window length is related to the fourth window length, the proxy cache data volume, and the window shrink volume. When any of the three factors changes, the third window length needs to be updated, that is, the proxy device sends a confirmation message to the server device to declare the updated third window length.

[0211] For example, after receiving the confirmation message reported by the client device, the proxy device extracts the fourth window length from the confirmation message, substitutes the fourth window length into Formula (1), calculates the third window length, and generates a confirmation message to send to the server device to update the third window length.

[0212] In another example, after the proxy device receives the confirmation message reported by the client device, the proxy cache data volume is updated according to the TSN of the confirmed downlink data in the confirmation message, the proxy cache data volume is substituted into Formula (1), the third window length is calculated, and a confirmation message is generated to send to the server device to update the third window length.

[0213] In another example, when the proxy device receives a data message issued by the server device, if the TSN indicates that it is a sequential message (not out of order or retransmission), the proxy cache data volume is updated, the proxy cache data volume is substituted into Formula (1), the third window length is calculated, and a confirmation message is generated to send to the server device to update the third window length.

[0214] In another example, if the window shrink volume is dynamically adjusted according to the proxy cache data volume, the window shrink volume can be substituted into Formula (1) to calculate the third window length, and a confirmation message is generated to send to the server device to update the third window length.

[0215] The third window length determined in the above manner has the following effects:

[0216] 1) It tries to ensure end-to-end consistency, so that even if the proxy is stopped in the middle, the business sustainability can be ensured, and the window consistency can be ensured;

[0217] 2) In the case of a clear air interface, the client device has insufficient capacity or high speed (the air interface rate is not the bottleneck), etc. In this case, the second window length fed back by the client device is small, the proxy cache data volume can be reduced, and the proxy device has small cache pressure.

[0218] 3) In the constant low rate scenario, the client device has low cache volume, even if the third window length is large, but considering the actual low rate, the TCP proxy cache pressure of the proxy device is also small.

[0219] 4) In the air interface extreme case (such as high speed download process air interface suddenly deteriorated, need to joint air interface judgment), need to be aware of and through the confirmation message in time to update (reduce) the third window length, avoid TCP proxy buffer pressure too large;

[0220] 5) Avoid CT segment and TS segment independent maintenance window length caused by TS segment "supply" much greater than the "demand" of CT segment, and then lead to the memory of the proxy device is wasted seriously.

[0221] On the basis of any of the above embodiments, in order to improve the software efficiency, for packet data convergence protocol (PDCP) and TCP proxy such message transceiver software, realize the vector packet processor (VPP) large loop framework, the embodiment of the application combines the frame number and time slot number mechanism of wireless software, and designs the timeout scheme of the following matching large loop software architecture, as shown in Figure 12 .

[0222] Figure 12 Another flowchart of a TCP proxy method provided by the embodiment of the application is provided. Please refer to Figure 12 , which comprises the following steps.

[0223] S1201, determine a timeout queue corresponding to each time slot in a frame period, and the timeout queue comprises a plurality of timeout events.

[0224] Exemplarily, one frame period corresponds to 2048 half frames (5ms), that is, 20480 time slot numbers, therefore, there are 20480 timeout queues in one frame period, as shown in Figure 13 .

[0225] Each timeout queue can be a double-linked list, and any specified node can be quickly deleted or inserted.

[0226] The timeout event can be an event to be executed after a specified timer expires.

[0227] In a possible implementation manner, the timeout queue corresponding to each time slot in a frame period can be determined in the following manner:

[0228] For any timer, determine the first half frame number and the first time slot number corresponding to the starting moment of the timer; determine the second half frame number and the second time slot number according to the first half frame number, the first time slot number and the timing duration of the timer; and add the timeout event corresponding to the timer to the timeout queue corresponding to the second half frame number and the second time slot number.

[0229] Each half frame number includes 10 time slot numbers, wherein the second time slot number is the time slot number in the second half frame number.

[0230] For example, if the second half frame number is 0 and the second time slot number is 1, the timer corresponding timeout event is added to the timeout queue corresponding to the second time slot number in the second half frame number.

[0231] S1202, determine the scanning period.

[0232] The scanning period can be the period between the scanning time of the first scanning event and the scanning time of the second scanning event.

[0233] If the scanning time of the first scanning event is a and the scanning time of the second scanning event is a+x, the scanning period is [a, a+x].

[0234] For example, if the current time corresponds to a scanning event, the period between the current time and the last scanning time is determined as the scanning period.

[0235] The length x of the scanning period can be determined according to actual conditions. For example, x can be 2ms.

[0236] The lengths of the two scanning periods can be the same or different.

[0237] The timer timeout judgment logic can be called based on the PDCP large cycle period, and the scanning event can be determined according to the timer timeout judgment logic.

[0238] S1203, process the timeout events in the multiple timeout queues corresponding to the scanning period.

[0239] The multiple timeout queues corresponding to the scanning period can be the timeout queues corresponding to the multiple time slot numbers corresponding to the scanning period.

[0240] For example, if the current time corresponds to a scanning event, the half frame number and the time slot number corresponding to the current time are obtained, and the half frame number and the time slot number corresponding to the last scanning time are compared to determine the multiple interval time slot numbers corresponding to the scanning period. All timeout events in the timeout queues corresponding to the multiple interval time slot numbers are processed.

[0241] Each timer corresponds to a timeout timer control block, and the timeout events can be processed according to the control block information of each timeout timer. Each control block information includes at least one of the following:

[0242] 1) Timer start time;

[0243] 2) Timing duration;

[0244] 3) Processing function to be called after timeout;

[0245] 4) All parameters required by the function.

[0246] The following gives an example of processing of different timers:

[0247] 1) CT segment data timeout retransmission timer: by counting the air interface RTT (smoothed), if no packet is received for more than 2 RTT, the corresponding data is triggered for timeout retransmission.

[0248] 2) TCP proxy link keep-alive timer: when no data is received for a specified period of time in the TS segment, the idle TCP proxy is triggered to close, and the TCP proxy link is deleted.

[0249] 3) Zero window length detection timer: after receiving the second window length of 0 reported by the client device, the timeout detection mechanism is started to prevent the client device from updating the second window length for a long time or the update packet being lost.

[0250] 4) TS segment confirmation delay confirmation timer: to improve confirmation efficiency and reduce the number of confirmation packets, N consecutive packets are received and a confirmation is sent once, but this may result in a long time without receiving N packets and being unable to confirm the last few packets, so a timer is started after receiving the first packet; in addition, the TS segment confirmation delay confirmation timer can be reused in the RTT smoothing stage.

[0251] 5) TCP proxy delay close timer: after the proxy device receives the specified user TCP proxy close message, a TCP proxy delay close timer is started for the client device, and after the timer expires, all TCP proxy links of the client device are set to TCP proxy close, and before the proxy delay close timeout, each TCP thread performs RTT smoothing strategy.

[0252] The timer mechanism based on the large loop framework of the frame number system set by the wireless software only scans and processes timeout events, without scanning all pending events, saving software overhead; and based on the large loop framework, the business data is not frequently interrupted, there is no task switching overhead, the Cache hit rate is significantly improved, and the lock mechanism avoids the system overhead of the lock.

[0253] Figure 14 A structural diagram of a TCP proxy device provided by an embodiment of the present application is shown in FIG. 1. As shown in the figure, the device includes a memory 1410, a transceiver 1420, and a processor 1430. Figure 14

[0254] The memory 1410 is configured to store a computer program.

[0255] The transceiver 1420 is configured to receive and transmit data under the control of the processor.

[0256] ​The processor 1430 is configured to read a computer program in the memory and perform the following operations:

[0257] The first message is received from a first device, and the first device is a client device or a server device.

[0258] According to the first message and a current state of the proxy device, a target state is determined, and the target state is any one of a link establishment state, a data transmission state, a first link deletion state, a second link deletion state, and a connectionless state.

[0259] The current state is switched to the target state.

[0260] In an embodiment, the processor 1430 is specifically configured to perform the following operations:

[0261] If the first message is a synchronization message and the current state is the connectionless state, the target state is determined to be the link establishment state; or

[0262] If the first message is a synchronization confirmation message and the current state is the link establishment state, the target state is determined to be the data transmission state; or

[0263] If the first message is a normal close connection message sent by the server device and the current state is the data transmission state, the target state is determined to be the first link deletion state; or

[0264] If the first message is an abnormal close connection message sent by the server device and the current state is the data transmission state, the target state is determined to be the second link deletion state; or

[0265] If the first message is an abnormal close connection message sent by the client device and the current state is the data transmission state, the target state is determined to be the connectionless state.

[0266] In an embodiment, when the target state is the first link deletion state or the second link deletion state, the processor 1330 is further configured to perform the following operations:

[0267] Data in a TCP proxy cache is sent to the client device until the TCP proxy cache is emptied.

[0268] The TCP link is deleted, and the connectionless state is switched to.

[0269] In an embodiment, the processor 1330 is further configured to perform the following operations:

[0270] The second message is sent to the server device, and the second message includes a first window length, and the first window length satisfies the following formula:

[0271] The first window length = min (second window length, theoretical proxy maximum window length)

[0272] The first window length indicates a maximum data amount of the first data packet, the first data packet is a data packet sent by the server device to the proxy device, the second window length indicates a theoretical maximum data amount of the second data packet, the second data packet is a data packet sent by the proxy device to the client device, and the theoretical proxy maximum window length indicates a theoretical maximum data amount of the first data packet.

[0273] In an embodiment, the processor 1430 is further configured to perform the following operation:

[0274] The third message includes a third window length, and the third window length indicates a data amount of the first data packet.

[0275] The third window length satisfies the following formula:

[0276] The third window length = the fourth window length - the proxy cache data amount - the window shrink amount.

[0277] The fourth window length indicates a data amount of the second data packet, the proxy cache data amount is a data amount in a TCP proxy cache of the proxy device, and the window shrink amount is a constant.

[0278] In an embodiment, the window shrink amount is a difference between the second window length and the first window length.

[0279] In an embodiment, the processor 1430 is further configured to perform the following operation:

[0280] Determine a timeout queue corresponding to each time slot in a frame period, and the timeout queue includes a plurality of timeout events.

[0281] Determine a scanning period.

[0282] Process the timeout events in the plurality of timeout queues corresponding to the scanning period.

[0283] In an embodiment, the processor 1430 is specifically configured to perform the following operation:

[0284] For any one timer, determine a first half frame number and a first time slot number corresponding to a starting moment of the timer.

[0285] According to the first half frame number, the first time slot number, and a timing duration of the timer, determine a second half frame number and a second time slot number.

[0286] Add a timeout event corresponding to the timer to a timeout queue corresponding to the second half frame number and the second time slot number.

[0287] The first half frame number and the second half frame number are determined according to the following formula: Figure 14In particular embodiments, the bus architecture can include any number of interconnecting buses and bridges, and the various circuitry representative of the processor 1430 and the memory 1410, for example, can be linked together by various wires and busses, represented generally by bus interface 1440. The bus architecture can also include various other circuitry that can be designed to link various circuitry together, and thus, is not further described herein. The bus interface provides an interface to the transceiver 1420. The transceiver 1420 can be a plurality of elements including a transmitter and a receiver, and provides a means for communicating with various other apparatus over a transmission medium, including a wireless channel, a wired channel, optical fiber cable, or the like. The processor 1430 is responsible for managing the bus architecture and generally carrying out the processing functions. The memory 1410 can store data used by the processor 1430 during execution of an operation.

[0288] The processor 1430 can be a central processing unit (CPU), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or a complex programmable logic device (CPLD), or the processor can be a multi-core architecture.

[0289] It should be noted that the above-mentioned device provided by the present application can realize all the method steps of the above-mentioned method embodiments, and achieve the same technical effects. Therefore, the same parts and beneficial effects of the method embodiments will not be described in detail.

[0290] Figure 15 Another structure schematic diagram of a TCP proxy device provided by the present application is provided. As shown in the figure, the device is applied to a proxy device, and the device comprises: Figure 15

[0291] The receiving unit 1510 is configured to receive a first packet sent by a first device, the first device being a client device or a server device.

[0292] The first determining unit 1520 is configured to determine a target state according to the first packet and a current state of the proxy device, the target state being any one of the following states: a link establishment state, a data transmission state, a first link deletion state, a second link deletion state, and a connectionless state.

[0293] The switching unit 1530 is configured to switch from the current state to the target state.

[0294] In an embodiment, the first determining unit 1520 is specifically configured to:​

[0295] if the first message is a synchronization message and the current state is the no connection state, then determining that the target state is the chain establishment state; or

[0296] if the first message is a synchronization confirmation message and the current state is the chain establishment state, then determining that the target state is the data transmission state; or

[0297] if the first message is a normal close connection message sent by the server device and the current state is the data transmission state, then determining that the target state is the first chain deletion state; or

[0298] if the first message is an abnormal close connection message sent by the server device and the current state is the data transmission state, then determining that the target state is the second chain deletion state; or

[0299] if the first message is an abnormal close connection message sent by the client device and the current state is the data transmission state, then determining that the target state is the no connection state.

[0300] In an implementation, when the target state is the first chain deletion state or the second chain deletion state, the apparatus further comprises:

[0301] a first sending unit, configured to send data in the TCP proxy cache to the client device until the TCP proxy cache is emptied;

[0302] a deletion unit, configured to delete the TCP link and switch to the no connection state.

[0303] In an implementation, the apparatus further comprises a second sending unit, configured to:

[0304] send a second message to the server device, the second message comprising a first window length, the first window length satisfying the following formula:

[0305] first window length = min(second window length, theoretical proxy maximum window length)

[0306] wherein the first window length indicates a maximum data amount of a first data packet, the first data packet being a data packet sent by the server device to the proxy device, the second window length indicates a theoretical maximum data amount of a second data packet, the second data packet being a data packet sent by the proxy device to the client device, and the theoretical proxy maximum window length indicates a theoretical maximum data amount of the first data packet.

[0307] In an implementation, the apparatus further comprises a third sending unit, configured to:

[0308] send a third message to the server device, the third message comprising a third window length, the third window length indicating a data amount of the first data packet;

[0309] The third window length satisfies the following formula:

[0310] The third window length = the fourth window length - the proxy cache data amount - the window shrink amount

[0311] The fourth window length indicates the data amount of the second data packet, the proxy cache data amount is the data amount in the TCP proxy cache of the proxy device, and the window shrink amount is a constant.

[0312] In an embodiment, the window shrink amount is the difference between the second window length and the first window length.

[0313] In an embodiment, the apparatus further comprises:

[0314] The second determining unit is configured to determine a timeout queue corresponding to each time slot in a frame period, and the timeout queue comprises a plurality of timeout events.

[0315] The third determining unit is configured to determine a scanning period.

[0316] The processing unit is configured to process the timeout events in the plurality of timeout queues corresponding to the scanning period.

[0317] In an embodiment, the second determining unit is further configured to:

[0318] For any one timer, determine the first half frame number and the first time slot number corresponding to the starting moment of the timer;

[0319] According to the first half frame number, the first time slot number, and the timing duration of the timer, determine the second half frame number and the second time slot number;

[0320] Add the timeout event corresponding to the timer to the timeout queue corresponding to the second half frame number and the second time slot number.

[0321] It should be noted that the division of units in the embodiments of the present application is illustrative, and is merely a logical functional division. In actual implementation, another division manner can be used. In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present alone, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0322] The integrated unit described above, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a processor-readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the various embodiments of the method of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0323] It should be noted that the above-mentioned device provided by the present application can realize all the method steps realized by the method embodiments and achieve the same technical effects. Therefore, the same parts and beneficial effects of the method embodiments will not be described in detail.

[0324] The present application also provides a processor-readable storage medium, which stores a computer program. The computer program is used to make a processor execute the method described in any one of the above method embodiments.

[0325] The processor-readable storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to a magnetic memory (such as a floppy disk, a hard disk, a magnetic tape, a magneto-optical disk (MO), etc.), an optical memory (such as a CD, a DVD, a BD, a HVD, etc.), and a semiconductor memory (such as a ROM, an EPROM, an EEPROM, a non-volatile memory (NAND FLASH), a solid-state disk (SSD), etc.), etc.

[0326] The present application also provides a computer program product, which includes a computer program. The computer program is executed by a processor to implement the method described in any one of the above method embodiments.

[0327] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer usable storage media (including but not limited to magnetic disk storage and optical storage, etc.) containing computer usable program codes.

[0328] The computer executable instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operations steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart Figure 1 one or more flows and / or functions specified in the flowchart Figure 1 one or more flows and / or functions specified in the flowchart

[0329] These processor-executable instructions can also be stored in a processor-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the processor-readable memory produce an article of manufacture including instructions which implement the functions specified in the flowchart Figure 1 one or more flows and / or functions specified in the flowchart Figure 1 one or more flows and / or functions specified in the flowchart

[0330] These processor-executable instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operations steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart Figure 1 one or more flows and / or functions specified in the flowchart Figure 1 Figure 1 one or more flows and / or functions specified in the flowchart

[0331] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. A TCP proxy method, characterized in that, The method is applied to a proxy device, which maintains a state machine, the state machine including the following states: connection establishment state, data transmission state, first connection deletion state, second connection deletion state, and connectionless state; the method includes: Receive a first message sent by a first device, where the first device is a client device or a server device; Based on the first message and the current state of the proxy device, a target state is determined, which can be any of the following: connection establishment state, data transmission state, first deletion state, second deletion state, and connectionless state. Switch from the current state to the target state.

2. The method according to claim 1, characterized in that, Based on the first message and the current state of the proxy device, the target state is determined, including: If the first message is a synchronization message and the current state is the connectionless state, then the target state is determined to be the connection-established state; or, If the first message is a synchronization confirmation message, and the current state is the connection establishment state, then the target state is determined to be the data transmission state; or, If the first message is a normal connection closure message sent by the server device, and the current state is the data transmission state, then the target state is determined to be the first deletion state; or, If the first message is an abnormal connection closure message sent by the server device, and the current state is the data transmission state, then the target state is determined to be the second deletion state; or, If the first message is an abnormal connection closure message sent by the client device, and the current state is the data transmission state, then the target state is determined to be the connectionless state.

3. The method according to claim 2, characterized in that, When the target state is the first deleted chain state or the second deleted chain state, the method further includes: Send the data from the TCP proxy cache to the client device until the TCP proxy cache is cleared; Delete the TCP link and switch to the connectionless state.

4. The method according to claim 1, characterized in that, The method further includes: Send a second message to the server device, the second message including a first window length, the first window length satisfying the following formula: First window length = min(second window length, theoretical maximum window length for the proxy) Wherein, the first window length indicates the maximum data size of the first data packet, which is the data packet sent by the server device to the proxy device; the second window length indicates the theoretical maximum data size of the second data packet, which is the data packet sent by the proxy device to the client device; and the theoretical maximum proxy window length indicates the theoretical maximum data size of the first data packet.

5. The method according to claim 4, characterized in that, The method further includes: Send a third message to the server device, the third message including a third window length, the third window length indicating the size of the first data packet; The length of the third window satisfies the following formula: Third window length = Fourth window length - Proxy cache data volume - Window shrinkage The fourth window length indicates the size of the second data packet, the proxy cache data size is the amount of data in the TCP proxy cache of the proxy device, and the window size is a constant.

6. The method according to claim 5, characterized in that, The window shrinkage amount is the difference between the second window length and the first window length.

7. The method according to claim 1, characterized in that, The method further includes: Determine a timeout queue for each time slot within a frame period, wherein the timeout queue includes multiple timeout events; Determine the scanning period; Timeout events in multiple timeout queues corresponding to the scanning period are processed.

8. The method according to claim 7, characterized in that, Determine the timeout queue for each time slot within a frame period, including: For any given timer, determine the first half-frame number and the first time slot number corresponding to the start time of the timer; The second half-frame number and the second time slot number are determined based on the first half-frame number, the first time slot number, and the timing duration of the timer. Add the timeout event corresponding to the timer to the timeout queue corresponding to the second half-frame number and the second time slot number.

9. A Transmission Control Protocol (TCP) proxy device, characterized in that, This is applied to a proxy device, which maintains a state machine. The state machine includes the following states: connection establishment state, data transmission state, first connection deletion state, second connection deletion state, and connectionless state. The device includes a memory, a transceiver, and a processor. The memory is used to store computer programs; the transceiver is used to send and receive data under the control of the processor; the processor is used to read the computer programs in the memory and perform the following operations: Receive a first message sent by a first device, where the first device is a client device or a server device; Based on the first message and the current state of the proxy device, a target state is determined, which can be any of the following: connection establishment state, data transmission state, first deletion state, second deletion state, and connectionless state. Switch from the current state to the target state.

10. The apparatus according to claim 9, characterized in that, The processor is specifically used to perform the following operations: If the first message is a synchronization message and the current state is the connectionless state, then the target state is determined to be the connection-established state; or, If the first message is a synchronization confirmation message and the current state is the connection establishment state, then the target state is determined to be the data transmission state. or, If the first message is a normal connection closure message sent by the server device, and the current state is the data transmission state, then the target state is determined to be the first deletion state. or, If the first message is an abnormal connection closure message sent by the server device, and the current state is the data transmission state, then the target state is determined to be the second deletion state. or, If the first message is an abnormal connection closure message sent by the client device, and the current state is the data transmission state, then the target state is determined to be the connectionless state.

11. The apparatus according to claim 10, characterized in that, When the target state is the first deleted chain state or the second deleted chain state, the processor is further configured to perform the following operations: Send the data from the TCP proxy cache to the client device until the TCP proxy cache is cleared; Delete the TCP link and switch to the connectionless state.

12. The apparatus according to claim 9, characterized in that, The processor is also configured to perform the following operations: Send a second message to the server device, the second message including a first window length, the first window length satisfying the following formula: First window length = min(second window length, theoretical maximum window length for the proxy) Wherein, the first window length indicates the maximum data size of the first data packet, which is a data packet sent by the server device to the proxy device; the second window length indicates the theoretical maximum data size of the second data packet, which is a data packet sent by the proxy device to the client device; and the theoretical maximum proxy window length indicates the theoretical maximum data size of the first data packet.

13. The apparatus according to claim 12, characterized in that, The processor is also configured to perform the following operations: Send a third message to the server device, the third message including a third window length, the third window length indicating the size of the first data packet; The length of the third window satisfies the following formula: Third window length = Fourth window length - Proxy cache data volume - Window shrinkage The fourth window length indicates the size of the second data packet, the proxy cache data size is the amount of data in the TCP proxy cache of the proxy device, and the window size is a constant.

14. The apparatus according to claim 13, characterized in that, The window shrinkage amount is the difference between the second window length and the first window length.

15. The apparatus according to claim 9, characterized in that, The processor is also configured to perform the following operations: Determine a timeout queue for each time slot within a frame period, wherein the timeout queue includes multiple timeout events; Determine the scanning period; Timeout events in multiple timeout queues corresponding to the scanning period are processed.

16. The apparatus according to claim 15, characterized in that, The processor is specifically used to perform the following operations: For any given timer, determine the first half-frame number and the first time slot number corresponding to the start time of the timer; The second half-frame number and the second time slot number are determined based on the first half-frame number, the first time slot number, and the timing duration of the timer. Add the timeout event corresponding to the timer to the timeout queue corresponding to the second half-frame number and the second time slot number.

17. A Transmission Control Protocol (TCP) proxy device, characterized in that, Applied to a proxy device, the proxy device maintains a state machine, the state machine including the following states: connection establishment state, data transmission state, first connection deletion state, second connection deletion state, and connectionless state; the device includes: A receiving unit is configured to receive a first message sent by a first device, wherein the first device is a client device or a server device. The determining unit is configured to determine a target state based on the first message and the current state of the proxy device, wherein the target state is any one of the following: connection establishment state, data transmission state, first connection deletion state, second connection deletion state, and connectionless state; A switching unit is used to switch from the current state to the target state.

18. A processor-readable storage medium, characterized in that, The processor-readable storage medium stores a computer program for causing the processor to perform the method according to any one of claims 1 to 8.

19. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method and device for processing TCP connection

    CN101547210A