CN114422616A - Data communication method, client, server and system - Google Patents

Data communication method, client, server and system Download PDF

Info

Publication number
CN114422616A
CN114422616A CN202210113134.9A CN202210113134A CN114422616A CN 114422616 A CN114422616 A CN 114422616A CN 202210113134 A CN202210113134 A CN 202210113134A CN 114422616 A CN114422616 A CN 114422616A
Authority
CN
China
Prior art keywords
connection
request message
data
initiation time
client
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
CN202210113134.9A
Other languages
Chinese (zh)
Inventor
汪庆权
李志�
林俊龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou DPTech Technologies Co Ltd
Original Assignee
Hangzhou DPTech Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou DPTech Technologies Co Ltd filed Critical Hangzhou DPTech Technologies Co Ltd
Priority to CN202210113134.9A priority Critical patent/CN114422616A/en
Publication of CN114422616A publication Critical patent/CN114422616A/en
Withdrawn legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Abstract

The disclosure relates to a data communication method, a client, a server and a system, wherein the method comprises the following steps: a client sends a connection request message to a server, wherein a TCP socket of the connection request message adopts a quintuple with connection establishment initiation time; the server analyzes the connection request message and obtains the connection establishment initiation time, and the connection establishment initiation time is contained in a quintuple TCP socket which sends a connection response message to the client to respond to the connection request message, so that the connection between the client and the server is established; the client sends a data request message to the server by including the connection establishment initiation time in a TCP socket in the data request message; the server analyzes the data request message and obtains the connection establishment initiation time, and the connection establishment initiation time is contained in a quintuple TCP socket of a data response message sent to the client to respond to the data request message.

Description

Data communication method, client, server and system
Technical Field
The present disclosure relates to the field of data communication technologies, and in particular, to a data communication method, a client, a server, and a system.
Background
In the data communication process of the client/server mode, one party actively closing the connection enters a TIME-WAIT state after waving the ACK response message sent to the opposite end for the last TIME in four TIMEs. In this state, the active closing party WAITs for 2MSL (Maximum Segment Life, defined as 2min in RFC793, and defined as 30s in Linux), and if the FIN retransmitted by the passive closing party is not received within this TIME, the TIME _ WAIT state is changed to the CLOSED state.
RFC793 describes that the ISN (Initial Sequence Number) is incremented by 1 every 4 microseconds, and then starts from 0 after reaching 2^ 32. This cycle is repeated for an ISN period of about 4.55 hours. So although the SYN sequence number will not be the same each time a connection is established, if the receive window is large, the sequence number used by the fast re-established connection may partially overlap the sequence number used by the old connection, and thus there is a chance that the new connection will erroneously receive packets with the same sequence number as the old connection. In addition, the same four-tuple initiated connection before and after a short TIME overlaps with the four-tuple in the TIME _ WAIT state, and various processing needs to be performed according to various different conditions because the connection cannot be distinguished.
Generally, by turning on the net.ipv4.TCP _ tw _ reuse, net.ipv4.TCP _ timestamps system configuration options, the linux system will be able to multiplex connections in the TIME-WAIT state, which rely on TCP timestamps to distinguish connections initiated by the same quadruple before and after a short TIME for connections in the TIME-WAIT state by means of timestamps. Because the method depends on the TCP timestamp option, the TCP timestamp option needs to be started, and the old and new connections are indirectly distinguished according to the stored time. However, the connection initiated by the same quadruple before and after a short time cannot be distinguished by the quadruple, and the old and new connections cannot be clearly distinguished by the existing scheme. For example: the data packet with the sequence number n sent by the server for the first time is not sent to the client due to delay, and after the data packet with the sequence number n for the second time is retransmitted by the server, the client receives and actively disconnects. In a short time, the client initiates connection to the server again, at this time, the server sends data with sequence number n-2 and sequence number n-1 to the client, but the client also receives the data packet with sequence number n sent by the server for the first time in a delay way on the network. Because the new and old connections cannot be distinguished through the quadruple, in order to create a new connection, the old connection needs to be processed according to different conditions, and if the old connection can be aged or not, the new connection can be created or not, the processing logic is very complex.
Therefore, a data communication method, a client, a server and a system capable of distinguishing the same four-tuple initiated connection before and after a short time are needed.
Disclosure of Invention
In view of the above, the present disclosure provides a data communication method, a client, a server and a system. According to an aspect of the present disclosure, a data communication method is provided, which includes: a client sends a connection request message to a server, wherein a TCP socket of the connection request message adopts a quintuple with connection establishment initiation time; the server analyzes the connection request message and obtains the connection establishment initiation time, and the connection establishment initiation time is contained in a quintuple TCP socket which sends a connection response message to the client to respond to the connection request message, so that the connection between the client and the server is established; the client sends a data request message to the server by including the connection establishment initiation time in a TCP socket in the data request message; the server analyzes the data request message and obtains the connection establishment initiation time, and the connection establishment initiation time is contained in a quintuple TCP socket of a data response message sent to the client to respond to the data request message.
According to the data communication method of the present disclosure, it further includes: the server side sets the connection establishment initiation time of the received connection request message to be 0 under the condition that the connection request message of the TCP socket containing the quadruplet is analyzed and the connection establishment initiation time is not acquired; and the server side sends a connection request message aiming at the connection establishment initiation time of 0 to a client side which sends a connection request not containing the connection establishment initiation time and a connection response message containing a four-tuple TCP socket.
According to the data communication method of the present disclosure, it further includes: and the server inquires a connection table of the server based on the quintuple containing the connection establishment initiation time obtained by analyzing the connection request message, and stores the quintuple containing the connection establishment initiation time as a new connection item in the connection table under the condition that the five tuple containing the connection establishment initiation time is not contained in the connection table.
According to a second aspect of the present disclosure, a data communication client is provided, including: the message sending component is used for sending a connection request message or a data request message, and the TCP sockets of the connection request message and the data request message adopt quintuple containing connection establishment initiation time; and the data receiving component is used for receiving the connection response message or the data response message from the server, analyzing the connection response message or the data response message to acquire the connection establishment initiation time contained in the TCP socket of the connection response message or the data response message, establishing connection based on a quintuple containing the connection establishment initiation time or performing data packet packaging on the data response message containing the same connection establishment initiation time and then presenting the data response message to a user.
According to the data communication client of the present disclosure, the message sending module further includes: and the connection establishment initiation time acquisition component is used for acquiring the system time of the client as the connection establishment initiation time when constructing the connection request message, and the connection establishment initiation time is in nanosecond unit.
According to a third aspect of the present disclosure, a data communication server is provided, including: the message receiving component is used for receiving a connection request message or a data request message initiated by a client and analyzing and acquiring connection establishment initiation time contained in a TCP socket in the connection request message or the data request message; and the data sending component is used for responding to the data request message by including the connection establishment initiation time in a quintuple TCP socket of a data response message sent to the client.
According to the data communication server of this disclosure, it still includes: a detection component for detecting whether the parsed TCP socket includes a connection request establishment time; and a connection time setting component, which sets the connection request establishment time of the connection request message to 0 when the detection component detects that the TCP socket does not contain the connection request establishment time.
According to the data communication server of this disclosure, it still includes: a query component for querying a connection table based on a quintuple containing the connection establishment initiation time obtained by analyzing the connection request message; and the storage component stores the quintuple containing the connection establishment initiation time as a new connection item in the connection table under the condition that the query component does not query the quintuple containing the connection establishment initiation time in the connection table.
According to a fourth aspect of the present disclosure, a data communication system is provided, which includes: client and server rather than communication through the internet, wherein the client includes: the message sending component is used for sending a connection request message or a data request message, and the TCP sockets of the connection request message and the data request message adopt quintuple containing connection establishment initiation time; the data receiving assembly is used for receiving a connection response message or a data response message from a server, analyzing the connection response message or the data response message to acquire connection establishment initiation time contained in a TCP socket of the connection response message or the data response message, establishing connection based on a quintuple containing the connection establishment initiation time or performing data packet packaging on the data response message containing the same connection establishment initiation time and then presenting the data response message to a user; and the server comprises: the message receiving component is used for receiving a connection request message or a data request message initiated by a client and analyzing and acquiring connection establishment initiation time contained in a TCP socket in the connection request message or the data request message; and the data sending component is used for responding to the data request message by including the connection establishment initiation time in a quintuple TCP socket of a data response message sent to the client.
According to the data communication system of the present disclosure, the connection establishment initiation time is in units of nanoseconds.
In summary, with the data communication method, the client, the server, and the system of the present disclosure, the transmitted message includes the connection establishment initiation time, so that the connection is identified according to the < client IP, the client port number, the server IP, the server port number, and the connection establishment initiation time >, and because the connection establishment initiation time has uniqueness, the problem that new and old connections cannot be distinguished when two quadruplets of the < client IP, the client port number, the server IP, and the server port number are initiated in a short time is solved, and the problem that data of old connections are received on new connections is solved; for the session supporting the establishment of the initiation TIME of the transmission connection, the connection can be quickly aged, the connection in a TIME-WAIT state can be greatly reduced, the memory occupation is reduced, the size of a connection table is reduced, the speed of searching the connection table is improved, and the resource consumption of a server is greatly reduced; for the connection which does not support the transmission connection to establish the initiation time, the processing is carried out according to the previous data communication method, the old connection is not influenced, and the compatibility is realized.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent by describing in detail exemplary embodiments thereof with reference to the attached drawings. The drawings described below are merely some embodiments of the present disclosure, and other drawings may be derived from those drawings by those of ordinary skill in the art without inventive effort.
Fig. 1 is a schematic flow chart diagram illustrating a data communication method according to an embodiment of the disclosure.
Fig. 2 is a schematic diagram illustrating a format of a connection establishment initiation time field used in the data communication method according to the embodiment of the disclosure.
Fig. 3 is a schematic processing flow diagram of a server side of the data communication method according to the embodiment of the disclosure after receiving a connection request message.
Fig. 4 is a schematic diagram of a data communication client according to an embodiment of the disclosure.
Fig. 5 is a schematic diagram illustrating a format of a connection establishment initiation time field adopted by a data communication client according to an embodiment of the disclosure.
Fig. 6 is a schematic diagram of a data communication server according to an embodiment of the present disclosure.
Fig. 7 is a schematic diagram of a data communication system according to an embodiment of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The same reference numerals denote the same or similar parts in the drawings, and thus, a repetitive description thereof will be omitted.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, systems, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the present disclosure.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
It is to be understood by those skilled in the art that the drawings are merely schematic representations of exemplary embodiments, and that the blocks or processes shown in the drawings are not necessarily required to practice the present disclosure and are, therefore, not intended to limit the scope of the present disclosure.
Fig. 1 is a schematic flow chart diagram illustrating a data communication method according to an embodiment of the disclosure. When the client and the server are in data communication, the client and the server complete the establishment of communication connection to form a data communication channel; and then, the client and the server transmit data.
As shown in fig. 1, in step S102, the client sends a connection request message to the server, where a TCP socket of the connection request message uses a five-tuple containing connection establishment initiation time. Specifically, the quintuple of the TCP packet socket includes: client IP, client port number, server IP, service port number, and connection setup initiation time. The client IP and the server IP can respectively position the network addresses of the two ends; the client port number and the service port number are used for respectively identifying application program processes at two communication ends; the connection establishment initiation time is used for identifying the time when the client initiates a connection request to the server. Although a five tuple is mentioned here, a six tuple or a seven tuple is also possible as long as it contains the connection establishment initiation time. Thus, references to "quintuple" herein are actually "quintuples" of "at least five" elements, rather than merely "five" elements.
The data communication method in the embodiment of the disclosure specifies the optional field in the TCP protocol message to indicate the connection request time field. Fig. 2 is a schematic diagram of a format of a connection establishment initiation time field adopted in the data communication method according to the embodiment of the present disclosure, which includes three parts: a kind field, a length field, and an info field. Wherein, the kind field can occupy 1 byte and is used for indicating the type; the length field may occupy 1 byte to specify the length; the info field may occupy n-2 bytes to represent specific information. More specifically, as shown in fig. 2, let kind take the value 249, and may also be configured and replaced with other unused option types of TCP; the length value is 10; the info value is the time when the client initiates a connection request to the server.
In step S104, the server sends a connection response packet including the connection establishment initiation time to the client. Specifically, after receiving a connection request message sent by a client, a server analyzes the connection request message and obtains the connection establishment initiation time, and the connection establishment initiation time is contained in a quintuple TCP socket which sends a connection response message to the client to respond to the connection request message, so that the connection between the client and the server is established. More specifically, when receiving and analyzing a connection request message, the server needs to check whether an optional field with a kid value of 249 is included, and if so, extracts an info field value in combination with a length field value, and includes the connection establishment initiation time in a five-tuple TCP socket of the connection response message when generating the connection response message sent to the client.
After receiving the connection response message of the server, the client indicates that the data communication channel between the client and the server is successfully established, and the client and the server can perform data communication. Specifically, the client sends a data request message to the server, and after receiving the data request message, the server responds to the data request of the client to generate a data response message, and returns the data response message to the client.
As shown in fig. 1, in step S106, the client sends a data request message including connection establishment initiation time to the server. Specifically, the client sends the data request message to the server by including the connection establishment initiation time in a TCP socket in the data request message.
In step S108, the server sends a data response packet including the connection establishment initiation time to the client. Specifically, after receiving a data request message sent by a client, a server analyzes the data request message and obtains the connection establishment initiation time, and the connection establishment initiation time is contained in a quintuple TCP socket of a data response message sent to the client to respond to the data request message.
Optionally, the server sets the connection establishment initiation time of the received connection request message to 0 when analyzing the connection request message of the TCP socket containing the quadruplet without acquiring the connection establishment initiation time; and the server side sends a connection request message aiming at the connection establishment initiation time of 0 to a client side which sends a connection request not containing the connection establishment initiation time and a connection response message containing a four-tuple TCP socket.
Fig. 3 is a schematic processing flow diagram of a server side of the data communication method according to the embodiment of the disclosure after receiving a connection request message. Specifically, as shown in fig. 3, after the server receives the connection request message in step S302, the server parses the connection request message, and if the result of determining whether the connection request message includes the connection establishment initiation time is yes in step S304, the method proceeds to step S306. More specifically, in step S304, it is determined whether the connection request packet includes a TCP optional field with a kid value of 249, and if so, the connection request packet represents that the client side that sends the connection request packet supports establishing a session including the connection request establishment time. In step S306, the server extracts the five-tuple field information contained in the header of the connection request packet, and generates a five-tuple of < client IP, client port, server IP, service port, connection establishment initiation time >.
When the result of determining whether the header of the connection request message includes the connection establishment initiation time is no at step S304, the flow proceeds to step S308. More specifically, in step S304, it is determined whether the connection request packet includes a TCP optional field with a kid value of 249, and if not, it represents that the client sending the connection request packet does not support establishing a session including the connection request establishment time. In step S308, after the server sets the connection establishment initiation time to 0, a five-tuple of < client IP, client port, server IP, service port, connection establishment time > is generated.
When the server generates a connection response message, the server sends the connection request message aiming at the connection establishment initiation time of 0 to a client sending a connection request not containing the connection establishment initiation time, wherein the connection request message contains a four-tuple TCP socket. Specifically, if the connection establishment initiation time is not 0, the client sending the connection request message to the server supports establishment of a session including the connection establishment initiation time, and therefore the response message returned by the server needs to include the connection establishment initiation time in a TCP socket of the connection response message; if the connection establishment initiation time in the connection table is 0, the client sending the connection request message to the server does not support establishment of the session containing the connection establishment initiation time, so that the response message returned by the server does not contain the connection establishment initiation time in the TCP socket of the connection response message.
Optionally, the server queries a connection table of a five-tuple containing the connection establishment initiation time obtained by parsing the connection request packet, and stores the five-tuple containing the connection establishment initiation time as a new connection item in the connection table when the five-tuple containing the connection establishment initiation time is not contained in the connection table.
More specifically, as shown in fig. 3, in step S310, the server queries the connection table of the service end based on the quintuple containing the connection establishment initiation time obtained by analyzing the connection request packet in step S306, and determines whether the result queried in the connection table is "no", and then proceeds to step S314; in step S314, the server searches the monitoring socket table according to the port, adds the quintuple as a new connection item to the connection table after finding the monitoring socket table, and then enters step S312; in step S312, the server performs subsequent processing according to the standard protocol stack. In step S310, the server queries the connection table based on the quintuple containing the connection establishment initiation time obtained by analyzing the connection request packet in step S306, and determines whether the result queried in the connection table is "yes" or not, and then proceeds to step S312; in step S312, the server performs subsequent processing according to the standard protocol stack. Specifically, if the quintuple containing the connection establishment initiation time is found in the connection table, indicating that the connection item is stored, the server performs subsequent processing according to the standard protocol stack.
Fig. 4 is a schematic diagram of a data communication client according to an embodiment of the disclosure. As shown in fig. 4, datacom client 40 includes a messaging component 402 and a data receiving component 404. A message sending component 402, configured to send a connection request message or a data request message, where a TCP socket of each of the connection request message and the data request message adopts a quintuple that includes connection establishment initiation time. The data receiving component 404 is configured to receive a connection response packet or a data response packet from a server, analyze the connection response packet or the data response packet to obtain connection establishment initiation time included in a TCP socket of the connection response packet or the data response packet, establish a connection based on a five-tuple including the connection establishment initiation time, or perform data packet packing on the data response packet including the same connection establishment initiation time, and then present the data response packet to a user.
As shown in fig. 4, in one embodiment, the messaging component 402 of the data communication client may further include 402a connection establishment initiation time acquisition component and sending component 402 b. The connection establishment initiation time obtaining component 402a is configured to obtain a system time of the client as a connection establishment initiation time when constructing the connection request packet, where the connection establishment initiation time is in nanoseconds. A sending component 402b, configured to send a connection request packet or a data request packet, where a TCP socket of each of the connection request packet and the data request packet adopts a quintuple that includes connection establishment initiation time. Fig. 5 is a schematic diagram illustrating a format of a connection establishment initiation time field adopted by a data communication client according to an embodiment of the disclosure. More specifically, as shown in fig. 5, the info field may include unix timestamps and nanoseconds, such as: the first 4 bytes of the info field are unix time stamps, indicating the number of seconds elapsed since 1/1970 (midnight of UTC/GMT), and the last 4 bytes are nanoseconds.
In one embodiment, after a data communication client initiates a data communication request, a kernel constructs a connection request message, a TCP selectable field is added, the TCP selectable field comprises a type kid of one byte, the kid value is 249, the length is 10 bytes, system time is acquired, unix timestamps and nanoseconds are filled, and the option value is stored in the kernel sock. All subsequent messages sent from the client to the server will carry the type and value of the option.
Fig. 6 is a schematic diagram of a data communication server according to an embodiment of the present disclosure. As shown in fig. 6, the data communication server 60 includes: a message receiving component 602 and a data sending component 612. The message receiving component 602 is configured to receive a connection request message or a data request message initiated by a client, and analyze and obtain connection establishment initiation time included in a TCP socket in the connection request message or the data request message. The data sending component 612 includes the connection establishment initiation time in a quintuple TCP socket of a data response packet sent to the client to respond to the data request packet.
Alternatively, as shown in fig. 6, the data communication server 60 further includes: a detection component 604 and a connection time setting component 606. Wherein the detecting component 604 is configured to detect whether the parsed TCP socket includes the connection request setup time. A connection time setting component 606, configured to set the connection request setup time of the connection request packet to 0 when the detection component detects that the TCP socket does not include the connection request setup time.
Alternatively, as shown in fig. 6, the data communication server 60 further includes: a query component 608 and a store component 610. Wherein, the query component 608 queries a connection table based on a quintuple containing the connection establishment initiation time obtained by analyzing the connection request message; and the storage component 610 stores the quintuple containing the connection establishment initiation time as a new connection item in the connection table under the condition that the five tuple containing the connection establishment initiation time is not inquired in the connection table by the inquiry component.
Fig. 7 illustrates a data communication system according to an embodiment of the present disclosure. As shown in fig. 7, the data communication system includes a client 702 and a server 704 communicating therewith via the internet. The client 702 includes a messaging component 702a and a data receiving component 702 b. A message sending component 702a, configured to send a connection request message or a data request message, where a TCP socket of each of the connection request message and the data request message adopts a quintuple having connection establishment initiation time; and a data receiving component 702b, configured to receive a connection response packet or a data response packet from a server, parse the connection response packet or the data response packet to obtain connection establishment initiation time included in a TCP socket of the connection response packet or the data response packet, establish a connection based on a five-tuple including the connection establishment initiation time, or perform data packing on the data response packet including the same connection establishment initiation time, and then present the data response packet to a user. And
as shown in fig. 7, server 704 includes a message receiving component 704a and a data sending component 704 b. The message receiving component 704a is configured to receive a connection request message or a data request message initiated by a client, and analyze and obtain connection establishment initiation time included in a TCP socket in the connection request message or the data request message; and a data sending component 704b that includes the connection establishment initiation time in a five-tuple TCP socket of a data response message sent to the client in response to the data request message.
Optionally, the connection establishment initiation time in the data communication system of the embodiment of the present disclosure is in nanoseconds.
In summary, with the data communication method, the client, the server, and the system of the present disclosure, the transmitted message includes the connection establishment initiation time, so that the connection is identified according to the < client IP, the client port number, the server IP, the server port number, and the connection establishment initiation time >, and because the connection establishment initiation time has uniqueness, the problem that new and old connections cannot be distinguished when two quadruplets of the < client IP, the client port number, the server IP, and the server port number are initiated in a short time is solved, and the problem that data of old connections are received on new connections is solved; for the session supporting the establishment of the initiation TIME of the transmission connection, the connection can be quickly aged, the connection in a TIME-WAIT state can be greatly reduced, the memory occupation is reduced, the size of a connection table is reduced, the speed of searching the connection table is improved, and the resource consumption of a server is greatly reduced; for the connection which does not support the transmission connection to establish the initiation time, the processing is carried out according to the previous data communication method, the old connection is not influenced, and the compatibility is realized.
In general, RFC793 describes that the ISN increments by 1 every 4 microseconds, starting with 0 after reaching 2^ 32. This cycle is repeated for an ISN period of about 4.55 hours. So although the SYN sequence number of TCP will not be the same each time a connection is established, if the receive window is large, the sequence number used by the fast re-established connection may partially overlap the sequence number used by the old connection, and therefore there is a chance that the new connection will erroneously receive packets with the same sequence number as the old connection. In addition, the same four-tuple initiated connection before and after a short TIME overlaps with the four-tuple in the TIME _ WAIT state, and various processing needs to be performed according to various different conditions because the connection cannot be distinguished.
The present disclosure actually provides a TCP optimization method, which provides a method for uniquely distinguishing new and old connections and distinguishing old and new data by extending TCP options, where the content is connection establishment time, and each packet of the subsequent flow includes connection establishment time. Whether the client side or the server side searches according to a quintuple of < source address, source port, destination address, destination port and connection establishment time >, but not according to a quadruple of < source address, source port, destination address and destination port >, the connection establishment time is unique, and the transmission data message carries the connection establishment time, so that the method for uniquely distinguishing the new and old connections and distinguishing the new and old data packets is provided. The problem that the traditional TCP solves the problem that the new connection and the old connection which are the same as the two quadruplets cannot be distinguished even if the two quadruplets are initiated in a short time is solved, and the problem that the data of the old connection is received on the new connection is further solved.
The technology provides a TCP optimization method, which increases connection establishment time when a client initiates TCP SYN handshake connection to a server, is generated when the client is connected, is carried by a TCP SYN message, carries the connection establishment time in a TCP custom expansion option, and carries the expansion option and an option value no matter whether the client sends the client to the server or the server sends the client to the client in the subsequent connection. The first field kind of the option indicates the type of the option and is a mandatory option, some TCP options have no last two fields and only contain a 1-byte kind field, the second field length (if any) specifies the total length of the option, which includes 2 bytes occupied by the kind field and the length field, and the third field info (if any) is specific information of the option. There are 7 common TCP options, e.g., kind-0, end of option table (EOP) option, one segment used only once. Put at the end for padding, indicating that there have been no more messages, the application data starts at the next 32-bit word; 1, No Operation (NOP) option, without special meaning, is generally used to pad the total length of the TCP option to an integer multiple of 4 bytes; when the maximum message segment length (MSS) option TCP connection is initialized, the two communication parties use the option to negotiate the maximum message segment length; and the timestamp option provides a more accurate method for calculating the loop Time (RTT) between the two communicating parties, thereby providing important information for TCP flow control. The invention adds the option of the connection establishment time to indicate the connection establishment time, and can be used for distinguishing the new connection from the old connection. The connection establishment time option comprises a type kid of one byte, the kid value is 249, other unused option types of the TCP can be configured and replaced, and the client and the server are unified. 1 byte in length, 10 bytes, 8 bytes of data, the first 4 bytes being unix time stamps, indicating the number of seconds elapsed since 1/1970 (midnight of UTC/GMT), and the last 4 bytes being nanoseconds.
In popular terms, a client initiates a request, a kernel constructs a TCP SYN message, a TCP connection establishment time expansion option is added, the type kind of one byte is included, the kind value is 249, the length is 10 bytes, system time is obtained, unix timestamps and nanoseconds are filled, and the option value is stored on the kernel sock. All subsequent messages sent from the client to the server will carry the type and value of the option. The server receives the message, analyzes the TCP handshake SYN message, analyzes the TCP layer, analyzes the TCP option, checks whether the option with TCP kid of 249 exists, if so, takes out the option value, stores the option value, generates a quintuple of < source address, source port, destination address, destination port and connection establishment time >, and if not, sets the connection establishment time value to 0. The present TCP protocol stack realizes searching according to four-tuple of < source address, source port, destination address, destination port >, the invention expands the connection establishment time option and then changes the searching according to five-tuple of < source address, source port, destination address, destination port, connection establishment time >. The connection table is looked up according to the quintuple and if found, the TCP protocol processes the connection table. If the connection table is not found, searching the monitoring socket table according to the port, adding the quintuple into the TCP connection table after finding, comparing with the former TCP protocol processing, and changing the added connection table from the quadruplet of the source address, the source port, the destination address and the destination port into the quintuple of the source address, the source port, the destination address and the destination port and the connection establishment time. For the connection which requires to carry the TCP connection establishment time, all messages which are replied to the client by the server side need to be added with a connection establishment time expansion option. Because the connection searching is carried out according to the quintuple instead of the quadruplet, even if the connection with the same two quadruplets is initiated in a short time, the unique connection can be found due to different connection establishment time, thereby solving the problems that the old and new data packets can not find the affiliated connection or rely on the TCP timestamp option to distinguish and also avoiding the data of the old connection being received on the new connection. In addition, connection searching is carried out according to the quintuple of < source address, source port, destination address, destination port and connection establishment time >, and connection initiated by the quadruplet is different in connection establishment time, so that connection can be quickly aged for a session supporting connection establishment time establishment, connection in a time-wait state can be greatly reduced, memory occupation is reduced, the size of a connection table is reduced, the speed of searching the connection table is improved, and the resource consumption of a server is greatly reduced.
According to the method and the system, the TCP protocol is optimized, the TCP connection establishment time option is added, the connection between the client and the server is changed from the former four-tuple identification connection into the five-tuple identification, the problem that the old connection and the new connection which are identical in two four-tuples and cannot be distinguished even if the old connection and the new connection are initiated in a short time is solved, and the problem that the data of the old connection is received on the new connection is solved. Meanwhile, for the session supporting the establishment of the connection establishment time, the connection can be quickly aged, the connection in the time-wait state can be greatly reduced, the memory occupation is reduced, the size of the connection table is reduced, the speed of searching the connection table is improved, and the resource consumption of the server is greatly reduced. For the connection which does not support the connection establishment time option, the connection is processed according to the old protocol stack flow, the old connection is not influenced, and the compatibility is realized.
The basic principles of the present disclosure have been described in connection with specific embodiments, but it should be noted that it will be understood by those skilled in the art that all or any of the steps or components of the method and apparatus of the present disclosure may be implemented in any computing device (including processors, storage media, etc.) or network of computing devices, in hardware, firmware, software, or a combination thereof, which can be implemented by those skilled in the art using their basic programming skills after reading the description of the present disclosure.
Thus, the objects of the present disclosure may also be achieved by running a program or a set of programs on any computing device. The computing device may be a general purpose device as is well known. Thus, the object of the present disclosure can also be achieved merely by providing a program product containing program code for implementing the method or apparatus. That is, such a program product also constitutes the present disclosure, and a storage medium storing such a program product also constitutes the present disclosure. It is to be understood that the storage medium may be any known storage medium or any storage medium developed in the future.
It is also noted that in the apparatus and methods of the present disclosure, it is apparent that individual components or steps may be disassembled and/or re-assembled. These decompositions and/or recombinations are to be considered equivalents of the present disclosure. Also, the steps of executing the series of processes described above may naturally be executed chronologically in the order described, but need not necessarily be executed chronologically. Some steps may be performed in parallel or independently of each other.
The above detailed description should not be construed as limiting the scope of the disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (10)

1. A method of data communication, comprising:
a client sends a connection request message to a server, wherein a TCP socket of the connection request message adopts a quintuple with connection establishment initiation time;
the server analyzes the connection request message and obtains the connection establishment initiation time, and the connection establishment initiation time is contained in a quintuple TCP socket which sends a connection response message to the client to respond to the connection request message, so that the connection between the client and the server is established;
the client sends a data request message to the server by including the connection establishment initiation time in a TCP socket in the data request message;
the server analyzes the data request message and obtains the connection establishment initiation time, and the connection establishment initiation time is contained in a quintuple TCP socket of a data response message sent to the client to respond to the data request message.
2. The method of claim 1, further comprising:
the server side sets the connection establishment initiation time of the received connection request message to be 0 under the condition that the connection request message of the TCP socket containing the quadruplet is analyzed and the connection establishment initiation time is not acquired; and
and the server side sends a connection request message aiming at the connection establishment initiation time of 0 to a client side which sends a connection request not containing the connection establishment initiation time and a connection response message containing a four-tuple TCP socket.
3. The method of claim 1, further comprising:
and the server inquires a connection table of the server based on the quintuple containing the connection establishment initiation time obtained by analyzing the connection request message, and stores the quintuple containing the connection establishment initiation time as a new connection item in the connection table under the condition that the five tuple containing the connection establishment initiation time is not contained in the connection table.
4. A data communication client, comprising:
the message sending component is used for sending a connection request message or a data request message, and the TCP sockets of the connection request message and the data request message adopt quintuple containing connection establishment initiation time;
and the data receiving component is used for receiving the connection response message or the data response message from the server, analyzing the connection response message or the data response message to acquire the connection establishment initiation time contained in the TCP socket of the connection response message or the data response message, establishing connection based on a quintuple containing the connection establishment initiation time or performing data packet packaging on the data response message containing the same connection establishment initiation time and then presenting the data response message to a user.
5. The client of claim 4, wherein the messaging component further comprises:
and the connection establishment initiation time acquisition component is used for acquiring the system time of the client as the connection establishment initiation time when constructing the connection request message, and the connection establishment initiation time is in nanosecond unit.
6. A data communication server, comprising:
the message receiving component is used for receiving a connection request message or a data request message initiated by a client and analyzing and acquiring connection establishment initiation time contained in a TCP socket in the connection request message or the data request message; and
and the data sending component is used for responding to the data request message by including the connection establishment initiation time in a quintuple TCP socket of a data response message sent to the client.
7. The server of claim 6, further comprising:
a detection component for detecting whether the parsed TCP socket includes a connection request establishment time; and
and the connection time setting component is used for setting the connection request establishment time of the connection request message to be 0 when the detection component detects that the TCP socket does not contain the connection request establishment time.
8. The server of claim 7, further comprising:
a query component for querying a connection table based on a quintuple containing the connection establishment initiation time obtained by analyzing the connection request message;
and the storage component stores the quintuple containing the connection establishment initiation time as a new connection item in the connection table under the condition that the query component does not query the quintuple containing the connection establishment initiation time in the connection table.
9. A data communication system, comprising: client and server communicating with the client through the internet, wherein
The client comprises: the message sending component is used for sending a connection request message or a data request message, and the TCP sockets of the connection request message and the data request message adopt quintuple containing connection establishment initiation time; the data receiving assembly is used for receiving a connection response message or a data response message from a server, analyzing the connection response message or the data response message to acquire connection establishment initiation time contained in a TCP socket of the connection response message or the data response message, establishing connection based on a quintuple containing the connection establishment initiation time or performing data packet packaging on the data response message containing the same connection establishment initiation time and then presenting the data response message to a user; and
the server includes: the message receiving component is used for receiving a connection request message or a data request message initiated by a client and analyzing and acquiring connection establishment initiation time contained in a TCP socket in the connection request message or the data request message; and the data sending component is used for responding to the data request message by including the connection establishment initiation time in a quintuple TCP socket of a data response message sent to the client.
10. The data communication system of claim 9, wherein the connection establishment initiation time is in nanoseconds.
CN202210113134.9A 2022-01-29 2022-01-29 Data communication method, client, server and system Withdrawn CN114422616A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210113134.9A CN114422616A (en) 2022-01-29 2022-01-29 Data communication method, client, server and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210113134.9A CN114422616A (en) 2022-01-29 2022-01-29 Data communication method, client, server and system

Publications (1)

Publication Number Publication Date
CN114422616A true CN114422616A (en) 2022-04-29

Family

ID=81278333

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210113134.9A Withdrawn CN114422616A (en) 2022-01-29 2022-01-29 Data communication method, client, server and system

Country Status (1)

Country Link
CN (1) CN114422616A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103067992A (en) * 2012-12-04 2013-04-24 大唐移动通信设备有限公司 Method and system for transmission control protocol (TCP) business processing
CN103259768A (en) * 2012-02-17 2013-08-21 中兴通讯股份有限公司 Method, system and device of message authentication
CN107070851A (en) * 2015-11-09 2017-08-18 韩国电子通信研究院 The system and method that the generation of connection fingerprint and stepping-stone based on network flow are reviewed
CN110771118A (en) * 2017-06-23 2020-02-07 华为技术有限公司 Seamless mobility and session continuity with TCP mobility options
CN111756776A (en) * 2020-07-28 2020-10-09 支付宝(杭州)信息技术有限公司 Server, message distribution device, program handover system, and program handover method
WO2021083284A1 (en) * 2019-10-31 2021-05-06 贵州白山云科技股份有限公司 Load balancing method and apparatus, medium and device
CN113595964A (en) * 2020-04-30 2021-11-02 华为技术有限公司 Connection tracking synchronization method, device, medium and equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103259768A (en) * 2012-02-17 2013-08-21 中兴通讯股份有限公司 Method, system and device of message authentication
CN103067992A (en) * 2012-12-04 2013-04-24 大唐移动通信设备有限公司 Method and system for transmission control protocol (TCP) business processing
CN107070851A (en) * 2015-11-09 2017-08-18 韩国电子通信研究院 The system and method that the generation of connection fingerprint and stepping-stone based on network flow are reviewed
CN110771118A (en) * 2017-06-23 2020-02-07 华为技术有限公司 Seamless mobility and session continuity with TCP mobility options
WO2021083284A1 (en) * 2019-10-31 2021-05-06 贵州白山云科技股份有限公司 Load balancing method and apparatus, medium and device
CN113595964A (en) * 2020-04-30 2021-11-02 华为技术有限公司 Connection tracking synchronization method, device, medium and equipment
CN111756776A (en) * 2020-07-28 2020-10-09 支付宝(杭州)信息技术有限公司 Server, message distribution device, program handover system, and program handover method

Similar Documents

Publication Publication Date Title
US6839751B1 (en) Re-using information from data transactions for maintaining statistics in network monitoring
US10091198B2 (en) Rule-based fingerprint generation methods and apparatus
CN109067938B (en) Method and device for testing DNS (Domain name Server)
JP2020113924A (en) Monitoring program, programmable device, and monitoring method
WO2016110273A1 (en) System and method for limiting access request
US7969900B2 (en) Determination of network performance characteristics
US7302491B2 (en) System and method of reducing data corruption due to recycled IP identification numbers
US7283527B2 (en) Apparatus and method of maintaining two-byte IP identification fields in IP headers
EP3065343B1 (en) Network monitoring method and apparatus, and packet filtering method and apparatus
CN107070719B (en) Equipment management method and device
US20050283639A1 (en) Path analysis tool and method in a data transmission network including several internet autonomous systems
US20080181215A1 (en) System for remotely distinguishing an operating system
CN108460044B (en) Data processing method and device
CN112737995B (en) Method, device and equipment for processing Ethernet frame and storage medium
CN111294264B (en) Communication method and device based on Modbus TCP protocol
CN114422616A (en) Data communication method, client, server and system
CN101741605B (en) Method, apparatus and system for processing message
US7231456B1 (en) 32-bit vendor-extended-type vendor specific attribute
CN111064729A (en) Message processing method and device, storage medium and electronic device
CN115002008B (en) Method, device, equipment and storage medium for measuring network delay
CN112989315B (en) Fingerprint generation method, device and equipment for terminal of Internet of things and readable storage medium
CN104969533B (en) A kind of data package processing method and device
CN113422760B (en) Data transmission method, device, electronic device and storage medium
CN106209666B (en) Link multiplexing method and system based on load balancer
CN112181670B (en) Inter-process communication method and device and Linux equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WW01 Invention patent application withdrawn after publication

Application publication date: 20220429

WW01 Invention patent application withdrawn after publication