CN113596068A - Method, device and server for establishing TCP connection - Google Patents

Method, device and server for establishing TCP connection Download PDF

Info

Publication number
CN113596068A
CN113596068A CN202010369814.8A CN202010369814A CN113596068A CN 113596068 A CN113596068 A CN 113596068A CN 202010369814 A CN202010369814 A CN 202010369814A CN 113596068 A CN113596068 A CN 113596068A
Authority
CN
China
Prior art keywords
client
address
server
communication
database
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.)
Granted
Application number
CN202010369814.8A
Other languages
Chinese (zh)
Other versions
CN113596068B (en
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.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology 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 Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202010369814.8A priority Critical patent/CN113596068B/en
Priority to PCT/CN2021/083415 priority patent/WO2021218520A1/en
Publication of CN113596068A publication Critical patent/CN113596068A/en
Application granted granted Critical
Publication of CN113596068B publication Critical patent/CN113596068B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/28Flow control; Congestion control in relation to timing considerations
    • 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]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The invention provides a method, a device and a server for establishing TCP connection, wherein if a connection request from a client is received, a response signal corresponding to the connection request is sent to the client; the connection request carries a client address of the client; obtaining a communication delay corresponding to a client address which is stored in advance; starting a preset timer at the same time, and setting a timeout value of the timer according to the communication delay; based on the timeout value, a TCP connection is established with the client. In the method, the timeout value of the started timer is set through the communication delay of the prestored server address and the corresponding client address, so that the condition that the time for the server to wait for the reply of the client is longer and longer due to the fact that the timeout value is larger and larger under the condition that the network state is poorer is avoided, and the speed of establishing the TCP connection between the client and the server is improved.

Description

Method, device and server for establishing TCP connection
Technical Field
The present invention relates to the field of network technologies, and in particular, to a method, an apparatus, and a server for establishing a TCP connection.
Background
When a client establishes TCP connection with a server, a SYN signal is sent to the server by the client, after receiving the SYN signal, the server sends the SYN signal and an ACK signal to the client, and simultaneously the client starts a timer and sets a timeout value of the timer, wherein the timeout value is usually set according to an RTT empirical value. If the timer reaches the timeout value and no ACK signal returned by the client is received, the server repeatedly sends a SYN signal and an ACK signal to the client, starts the timer again and sets the timeout value of the timer, and the timeout value is usually set according to the index value of the last timeout value. Under the condition of poor network state, the server needs to send multiple SYN signals and ACK signals, at the moment, the timeout value is increased in an exponential increase mode, the timeout value is larger and larger, the time for the server to wait for the reply of the client is longer and longer, and the speed for establishing connection between the client and the server is slower.
Disclosure of Invention
In view of the above, the present invention provides a method, an apparatus, and a server for establishing a TCP connection, so as to increase a speed of establishing a connection between a client and a server.
In a first aspect, an embodiment of the present invention provides a method for establishing a TCP connection, where the method includes: if a connection request from the client is received, sending a response signal corresponding to the connection request to the client; the connection request carries a client address of the client; obtaining a communication delay corresponding to a client address which is stored in advance; starting a preset timer, and setting a timeout value of the timer according to communication delay; based on the timeout value, a TCP connection is established with the client.
Further, the step of obtaining the communication delay corresponding to the address of the client, which is pre-stored, includes: acquiring communication time delay corresponding to the address of the client from a pre-established database; wherein, the database is established by the following method: and acquiring a historical communication record of the client corresponding to the client address, extracting communication delay from the historical communication record, and correspondingly storing the extracted communication delay and the client address into a database.
Further, the step of obtaining the communication delay corresponding to the client address from a pre-established database includes: if the communication delay corresponding to the client address cannot be obtained from the database, determining a first area range to which the client address belongs; and acquiring the communication delay corresponding to the client address in the first area range from the database, and determining the communication delay as the communication delay corresponding to the client address of the client.
Further, the database also stores: the server address of the server which communicates with the client corresponding to the client address in the historical communication record; correspondingly storing the address of the server, the address of the client and the communication delay; the method comprises the steps of obtaining communication time delay corresponding to a client address from a pre-established database, and comprises the following steps: acquiring a server address of a server receiving a connection request; and acquiring communication time delay corresponding to the client address and the server address from a pre-established database, and determining the communication time delay as the communication time delay corresponding to the client address of the client.
Further, the step of obtaining the communication delay corresponding to the client address and the server address from a pre-established database includes: if the communication time delay corresponding to the client address and the server address cannot be obtained from the database, determining a second area range to which the client address belongs; acquiring communication time delay corresponding to the address of the server and the address of the client in the second area range from the database; if the communication time delay corresponding to the address of the server and the address of the client in the second area range cannot be obtained from the database, determining a third area range to which the address of the server belongs; and acquiring the communication time delay corresponding to the client address in the second area range and the server address in the third area range from the database.
Further, the method further comprises: if the updated historical communication record of the client corresponding to the client address is obtained, extracting the updated communication delay from the updated historical communication record; and if the updated communication delay is smaller than the communication delay corresponding to the client address recorded in the database, correspondingly storing the updated communication delay and the client address into the database.
Further, the step of establishing a TCP connection with the client based on the timeout value includes: when the timing duration of the timer is less than the timeout value, receiving a response signal returned by the client, and determining that the TCP connection with the client is successfully established; if the timing duration of the timer reaches the timeout value, no response signal returned by the client is received, and the step of sending a response signal corresponding to the connection request to the client is continuously executed until the response signal returned by the client is received or a preset condition is met; wherein the preset conditions include: after receiving the connection request, the number of times of sending the response signal reaches a preset number threshold, or the time interval between the current time and the first time of sending the response signal meets a preset time threshold.
In a second aspect, an embodiment of the present invention provides an apparatus for establishing a TCP connection, where the apparatus includes: the signal sending module is used for sending a response signal corresponding to the connection request to the client if the connection request from the client is received; the connection request carries a client address of the client; the time delay acquisition module is used for acquiring the communication time delay corresponding to the client address which is stored in advance; the timeout value setting module is used for starting a preset timer and setting the timeout value of the timer according to the communication delay; and the TCP connection module is used for establishing TCP connection with the client based on the timeout value.
In a third aspect, an embodiment of the present invention provides a server, including a processor and a memory, where the memory stores machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the method for establishing a TCP connection according to any one of the embodiments of the first aspect.
In a fourth aspect, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions, which when invoked and executed by a processor, cause the processor to implement the method of establishing a TCP connection of any one of the embodiments of the first aspect.
The embodiment of the invention has the following beneficial effects:
the embodiment of the invention provides a method, a device and a server for establishing TCP connection, wherein if a connection request from a client is received, a response signal corresponding to the connection request is sent to the client; the connection request carries a client address of the client; obtaining a communication delay corresponding to a client address which is stored in advance; starting a preset timer at the same time, and setting a timeout value of the timer according to the communication delay; based on the timeout value, a TCP connection is established with the client. In the method, the timeout value of the started timer is set through the communication delay of the prestored server address and the corresponding client address, so that the condition that the time for the server to wait for the reply of the client is longer and longer due to the fact that the timeout value is larger and larger under the condition that the network state is poorer is avoided, and the speed of establishing the TCP connection between the client and the server is improved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method for establishing a TCP connection according to an embodiment of the present invention;
fig. 2 is a flowchart of another method for establishing a TCP connection according to an embodiment of the present invention;
fig. 3 is a flowchart of a method for obtaining a communication delay according to an embodiment of the present invention;
fig. 4 is a flowchart of another method for obtaining a communication delay according to an embodiment of the present invention;
fig. 5 is a flowchart of another method for obtaining a communication delay according to an embodiment of the present invention;
fig. 6 is a flowchart of another method for establishing a TCP connection according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an apparatus for establishing a TCP connection according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a server according to an embodiment of the present invention.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
At present, when a client establishes a TCP (Transmission Control Protocol) connection with a server, the client first sends a SYN (synchronization Sequence number) signal to the server, the server receives the SYN signal and then sends the SYN signal and an ACK (acknowledgement character) signal to the client, and the client starts a timer and sets a timeout value of the timer, which is usually set according to an RTT (Round-Trip Time) experience value. If the timer reaches the timeout value and no ACK signal returned by the client is received, the server repeatedly sends a SYN signal and an ACK signal to the client, starts the timer again and sets the timeout value of the timer, and the timeout value is usually set according to the index value of the last timeout value. Under the condition of poor network state, the server needs to send multiple SYN signals and ACK signals, at the moment, the timeout value is increased in an exponential increase mode, the timeout value is larger and larger, the time for the server to wait for the reply of the client is longer and longer, and the speed for establishing connection between the client and the server is slower.
Based on this, the method, the device and the server for establishing the TCP connection provided by the embodiments of the present invention can be applied to network connections of clients such as computers and mobile phones. For the convenience of understanding the embodiment, a detailed description will be first given of a method for establishing a TCP connection disclosed in the embodiment of the present invention.
First, an embodiment of the present invention provides a method for establishing a TCP connection, and as shown in fig. 1, the method includes the following steps:
step S102, if receiving a connection request from a client, sending a response signal corresponding to the connection request to the client; the connection request carries a client address of the client;
the client may be a mobile terminal device such as a computer and a mobile phone, and the server may be a device such as a server. The connection request may be a SYN signal sent by the client, and the response signal may be a SYN signal and an ACK signal sent by the server, so as to notify the client of the confirmation of the connection request signal. The client address of the client may be an IP (Internet Protocol) address of the client. Specifically, when a TCP connection is established, a client sends a connection request SYN signal to a server, which includes an IP address of the client, and after receiving the SYN signal, the server must confirm the SYN signal of the client, and simultaneously sends a response signal, which includes a SYN signal and an ACK signal.
Step S104, obtaining a communication delay corresponding to a client address which is saved in advance;
the communication delay may be RTT (Round-Trip Time), which is also an important performance indicator in a computer network, and represents the total delay experienced from the Time when the server sends data to the Time when the server receives an acknowledgement signal from the client. Since the connection request carries the client address of the client, the calculated RTT has the corresponding server address and client address when the server and the client are in communication connection, and thus the communication delay saved in advance can be set by the calculated RTT.
Step S106, starting a preset timer, and setting a timeout value of the timer according to the communication delay;
usually, the server sends the SYN signal and the ACK signal at the same time, and starts a preset timer, which can record the time from the sending of the signal to the receiving of the signal. The timeout value may be set according to the calculated RTT, i.e., the communication delay.
Step S108, based on the timeout value, a TCP connection is established with the client.
Specifically, after a preset timer is started, if the timing time of the timer exceeds a timeout value, the server side sends a response signal to the client side again until a TCP connection is established with the client side; in addition, after the server side sends signals for many times and the timer is overtime, the connection times of the server side exceeds a preset value, or the accumulated timing time of the timer exceeds preset time, and the connection between the server side and the client side fails.
The embodiment of the invention provides a method for establishing TCP connection, which comprises the steps of sending a response signal corresponding to a connection request to a client if the connection request from the client is received; the connection request carries a client address of the client; obtaining a communication delay corresponding to a client address which is stored in advance; starting a preset timer at the same time, and setting a timeout value of the timer according to the communication delay; based on the timeout value, a TCP connection is established with the client. In the method, the timeout value of the started timer is set through the communication delay of the prestored server address and the corresponding client address, so that the condition that the time for the server to wait for the reply of the client is longer and longer due to the fact that the timeout value is larger and larger under the condition that the network state is poorer is avoided, and the speed of establishing the TCP connection between the client and the server is improved.
The embodiment of the invention provides another method for establishing TCP connection, which is realized on the basis of the method of the embodiment; this embodiment mainly describes a specific implementation process of the step of obtaining a pre-stored communication delay corresponding to the client address (implemented by step S204), as shown in fig. 2, the method includes the following steps:
step S202, if a connection request from the client is received, a response signal corresponding to the connection request is sent to the client; the connection request carries a client address of the client;
step S204, obtaining communication time delay corresponding to the address of the client from a pre-established database;
the pre-established database may store a plurality of communication delays corresponding to a plurality of server addresses and a plurality of client addresses when establishing a connection;
wherein, the database is established by the following method: acquiring a historical communication record of a client corresponding to the client address, extracting communication time delay from the historical communication record, and correspondingly storing the extracted communication time delay and the client address into a database;
because the connection request carries the client address of the client, the historical communication record of the client, such as the communication record with the server in the last month, can be obtained through the client address; the communication record may include information such as communication delay when establishing a connection with one or more servers. The communication delay when the connection is established with the current server can be extracted from the historical communication record, and the extracted communication delay and the address of the client are correspondingly stored in the database.
For the above step S204, referring to a flowchart of a method for obtaining communication delay shown in fig. 3, a specific implementation process of the step of obtaining communication delay corresponding to the address of the client from a pre-established database is included in the method, where the method includes the following steps:
step S301, if the communication time delay corresponding to the client address is not obtained from the database, determining a first area range to which the client address belongs;
the first area range to which the client address belongs may be an IP address near a region where the client address is located, for example, the first area range may be an IP address of another client in a range of one hundred meters in the region where the client address is located.
Step S302, obtaining a communication delay corresponding to the client address in the first area range from the database, and determining the communication delay as the communication delay corresponding to the client address of the client.
If the communication delay corresponding to the client address is obtained through the first area range, the communication delay can be determined as the communication delay corresponding to the client address of the client; meanwhile, the communication delay and the client address can be correspondingly stored in the database so as to meet the richness and the real-time performance of the database.
Further, the database also stores: the server address of the server which communicates with the client corresponding to the client address in the historical communication record; correspondingly storing the address of the server, the address of the client and the communication delay; referring to another method flowchart for obtaining communication delay shown in fig. 4, a specific implementation process of the step of obtaining communication delay corresponding to the address of the client from a pre-established database includes the following steps:
step S401, obtaining the address of the server receiving the connection request;
step S402, obtaining the communication time delay corresponding to the client address and the server address from the pre-established database, and determining the communication time delay as the communication time delay corresponding to the client address of the client.
The communication delay represents the delay of the connection between the server and the client, so that the communication delay stored in the database not only needs to have the corresponding client address, but also can have the corresponding server address; specifically, the server address of the server that receives the connection request may be directly acquired, then the communication delay corresponding to the client address and the acquired server address is acquired from a pre-established database, and the communication delay is determined as the communication delay corresponding to the client address of the client.
With reference to the above step S402, referring to another flowchart of the method for obtaining communication delay shown in fig. 5, a specific implementation process of the step of obtaining communication delay corresponding to the client address and the server address from a pre-established database is shown in fig. 5, where the method includes the following steps:
step S501, if the communication time delay corresponding to the client address and the server address cannot be obtained from the database, determining a second area range to which the client address belongs;
the second area range to which the client address belongs may be other IP addresses near the area where the client address is located, for example, the IP addresses of other clients within a range of one hundred meters in the area where the client address is located.
Step S502, obtaining communication time delay corresponding to the address of the server and the address of the client in the second area range from the database;
after acquiring other client addresses in the second area range, the communication delay corresponding to the server address and the client address in the second area range can be searched in the database.
Step S503, if the communication time delay corresponding to the address of the server and the address of the client in the second area range is not obtained from the database, determining a third area range to which the address of the server belongs;
the third area range to which the server address belongs may be other IP addresses near the area where the server address is located, for example, the third area range may be IP addresses of other servers in a range of one hundred meters in the area where the server address is located.
Step S504, a communication delay corresponding to the address of the client in the second area range and the address of the server in the third area range is obtained from the database.
After acquiring the addresses of other clients in the second area range and the IP addresses of other servers in the third area range, the corresponding communication delay may be acquired from the database.
Step S206, starting a preset timer, and setting a timeout value of the timer according to the communication delay;
step S208, based on the timeout value, a TCP connection is established with the client.
In addition, the method also comprises the implementation process of the step of updating the database, and the implementation process comprises the following steps of:
if the updated historical communication record of the client corresponding to the client address is obtained, extracting the updated communication delay from the updated historical communication record;
and if the updated communication delay is smaller than the communication delay corresponding to the client address recorded in the database, correspondingly storing the updated communication delay and the client address into the database.
Usually, the same client and the same server may have multiple communication records, and if the communication delay between the same client and the same server is already stored in the database and then the client and the server are in communication connection, the communication delay is updated to the history record. And meanwhile, comparing the updated communication delay with the historical communication delay stored in the database before, if the updated communication delay is smaller than the communication delay corresponding to the client address recorded in the database, correspondingly storing the updated communication delay and the client address into the database so as to ensure the real-time property of the database. In addition, if the updated communication delay is larger than the communication delay corresponding to the client address recorded in the database, no processing is performed.
In the method, corresponding communication time delay is extracted through a historical communication record of a client; establishing a database according to the address of the client, the address of the server and the communication delay corresponding to the client and the server; by means of configuration, communication time delay corresponding to a client address and a server address which are establishing connection in a database is obtained to set a timeout value of a started timer, and under the condition that a network state is poor, the condition that the time for the server to wait for the client to reply is longer and longer due to the fact that the timeout value is larger and larger is avoided, and the speed of establishing TCP connection between the client and the server is improved.
The embodiment of the invention provides another method for establishing TCP connection, which is realized on the basis of the method of the embodiment; this embodiment focuses on a specific implementation process of the step of establishing a TCP connection with the client based on the timeout value (specifically implemented by steps S608-S610), as shown in fig. 6, the method includes the following steps:
step S602, if a connection request from a client is received, a response signal corresponding to the connection request is sent to the client; the connection request carries a client address of the client;
step S604, obtaining a communication delay corresponding to the address of the client terminal which is saved in advance;
step S606, starting a preset timer, and setting a timeout value of the timer according to the communication delay;
step S608, when the timing duration of the timer is less than the timeout value, receiving a response signal returned by the client, and determining that the TCP connection with the client is successfully established;
the method comprises the steps that a preset timer is started while a response signal corresponding to a connection request is sent to a client by a server, the timer keeps timing until a signal for confirming connection sent by the client is received, the server receives the signal for confirming connection sent by the client under the condition that the timing duration of the timer is smaller than a timeout value, the timer stops timing, and meanwhile, the TCP connection establishment success with the client is confirmed.
Step S610, if the timing duration of the timer reaches the timeout value, the response signal returned by the client is not received, and the step of sending the response signal corresponding to the connection request to the client is continuously executed until the response signal returned by the client is received or the preset condition is met;
if the timing duration of the timer reaches the timeout value, the server does not receive a connection confirmation signal sent by the client, and the timer stops timing; and then the server side continuously sends a response signal corresponding to the connection request to the client side, and simultaneously starts the timer again until the server side receives a response signal returned by the client side, and stops timing. Or under the condition that the server side does not receive the response signal returned by the client side all the time, stopping connection and displaying connection failure after the preset condition is met.
Wherein the preset conditions include: after receiving the connection request, the number of times of sending the response signal reaches a preset number threshold, or the time interval between the current time and the first time of sending the response signal meets a preset time threshold.
The time threshold and the time threshold may be set according to a history record of a specific client, for example, the time threshold may be 10, 15, etc.; the time threshold may be 1 minute, 5 minutes, etc. Specifically, after receiving the connection request, the server sends a response signal to the client, starts a timer to start timing, and if the timing duration reaches a timeout value, the server does not receive a connection confirmation signal sent by the client, and sends the response signal to the client again until the number of times of sending the response signal reaches a preset number threshold, the server stops the connection, and displays that the connection fails. Or, if the timing duration reaches the timeout value, the server does not receive a connection confirmation signal sent by the client, the server sends a response signal to the client again, starts the timer again to start timing, and stops connection and displays that the connection fails until the time interval between the current time and the time when the response signal is sent for the first time meets the preset time threshold.
In the method, the connection is directly established by comparing the timing duration of the timer with the timeout value under the condition that the timing duration is less than the timeout value; under the condition that the timing duration is greater than the timeout value, the timer is started again, the preset condition is set, and the connection is terminated in time.
Corresponding to the above method embodiment for establishing a TCP connection, an embodiment of the present invention further provides a schematic structural diagram of an apparatus for establishing a TCP connection, as shown in fig. 7, where the apparatus includes:
a signal sending module 71, configured to send a response signal corresponding to the connection request to the client if the connection request from the client is received; the connection request carries a client address of the client;
a delay obtaining module 72, configured to obtain a communication delay corresponding to the client address that is pre-stored;
a timeout value setting module 73, configured to start a preset timer, and set a timeout value of the timer according to a communication delay;
and a TCP connection module 74 configured to establish a TCP connection with the client based on the timeout value.
Further, the delay obtaining module is configured to: acquiring communication time delay corresponding to the address of the client from a pre-established database; wherein, the database is established by the following method: and acquiring a historical communication record of the client corresponding to the client address, extracting communication delay from the historical communication record, and correspondingly storing the extracted communication delay and the client address into a database.
Further, the delay obtaining module is configured to: if the communication delay corresponding to the client address cannot be obtained from the database, determining a first area range to which the client address belongs; and acquiring the communication delay corresponding to the client address in the first area range from the database, and determining the communication delay as the communication delay corresponding to the client address of the client.
Further, the database also stores: the server address of the server which communicates with the client corresponding to the client address in the historical communication record; correspondingly storing the address of the server, the address of the client and the communication delay;
further, the delay obtaining module is configured to: acquiring a server address of a server receiving a connection request; and acquiring communication time delay corresponding to the client address and the server address from a pre-established database, and determining the communication time delay as the communication time delay corresponding to the client address of the client.
Further, the delay obtaining module is configured to: if the communication time delay corresponding to the client address and the server address cannot be obtained from the database, determining a second area range to which the client address belongs; acquiring communication time delay corresponding to the address of the server and the address of the client in the second area range from the database; if the communication time delay corresponding to the address of the server and the address of the client in the second area range cannot be obtained from the database, determining a third area range to which the address of the server belongs; and acquiring the communication time delay corresponding to the client address in the second area range and the server address in the third area range from the database.
Further, the device further comprises a database updating module, configured to extract an updated communication delay from the updated historical communication record if the updated historical communication record of the client corresponding to the client address is obtained; and if the updated communication delay is smaller than the communication delay corresponding to the client address recorded in the database, correspondingly storing the updated communication delay and the client address into the database.
Further, the TCP connection module is configured to: when the timing duration of the timer is less than the timeout value, receiving a response signal returned by the client, and determining that the TCP connection with the client is successfully established; if the timing duration of the timer reaches the timeout value, no response signal returned by the client is received, and the step of sending a response signal corresponding to the connection request to the client is continuously executed until the response signal returned by the client is received or a preset condition is met; wherein the preset conditions include: after receiving the connection request, the number of times of sending the response signal reaches a preset number threshold, or the time interval between the current time and the first time of sending the response signal meets a preset time threshold.
The embodiment of the invention provides a device for establishing TCP connection, which is characterized in that if a connection request from a client is received, a response signal corresponding to the connection request is sent to the client; the connection request carries a client address of the client; obtaining a communication delay corresponding to a client address which is stored in advance; starting a preset timer at the same time, and setting a timeout value of the timer according to the communication delay; based on the timeout value, a TCP connection is established with the client. In the method, the timeout value of the started timer is set through the communication delay of the prestored server address and the corresponding client address, so that the condition that the time for the server to wait for the reply of the client is longer and longer due to the fact that the timeout value is larger and larger under the condition that the network state is poorer is avoided, and the speed of establishing the TCP connection between the client and the server is improved.
The apparatus for establishing a TCP connection according to the embodiment of the present invention has the same technical features as the method for establishing a TCP connection according to the above embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
An embodiment of the present invention further provides a server, as shown in fig. 8, where the server includes a processor 80 and a memory 81, where the memory 81 stores machine executable instructions capable of being executed by the processor 80, and the processor 80 executes the machine executable instructions to implement the method for establishing a TCP connection.
Further, the server shown in fig. 8 further includes a bus 82 and a communication interface 83, and the processor 80, the communication interface 83 and the memory 81 are connected through the bus 82.
The Memory 81 may include a high-speed Random Access Memory (RAM) and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 83 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, etc. may be used. Bus 82 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 8, but that does not indicate only one bus or one type of bus.
The processor 80 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 80. The Processor 80 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory 81, and the processor 80 reads information in the memory 81 and performs the steps of the method of the previous embodiment in combination with hardware thereof.
The embodiment of the present invention further provides a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the method for establishing a TCP connection.
The method, the apparatus, and the computer program product of the server for establishing a TCP connection provided in the embodiments of the present invention include a computer readable storage medium storing program codes, where instructions included in the program codes may be used to execute the method described in the foregoing method embodiments, and specific implementation may refer to the method embodiments, and will not be described herein again.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In addition, in the description of the embodiments of the present invention, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meaning of the above terms in the present invention can be understood in specific cases for those skilled in the art.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that the following embodiments are merely illustrative of the present invention, and not restrictive, and the scope of the present invention is not limited thereto: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A method of establishing a TCP connection, the method comprising:
if a connection request from a client is received, sending a response signal corresponding to the connection request to the client; wherein, the connection request carries the client address of the client;
obtaining a communication delay corresponding to the address of the client terminal which is saved in advance;
starting a preset timer, and setting a timeout value of the timer according to the communication delay;
and establishing a TCP connection with the client based on the timeout value.
2. The method of claim 1, wherein the step of obtaining a pre-stored communication delay corresponding to the client address comprises:
acquiring communication delay corresponding to the client address from a pre-established database;
wherein the database is established by: and acquiring a historical communication record of the client corresponding to the client address, extracting communication delay from the historical communication record, and correspondingly storing the extracted communication delay and the client address into the database.
3. The method according to claim 2, wherein the step of obtaining the communication delay corresponding to the client address from a pre-established database comprises:
if the communication delay corresponding to the client address is not obtained from the database, determining a first area range to which the client address belongs;
and acquiring the communication delay corresponding to the client address in the first area range from the database, and determining the communication delay as the communication delay corresponding to the client address of the client.
4. The method of claim 2, wherein the database further stores: the server address of the server communicating with the client corresponding to the client address in the historical communication record; the server address, the client address and the communication delay are correspondingly stored;
the step of obtaining the communication delay corresponding to the client address from a pre-established database includes:
acquiring the server address of the server receiving the connection request;
and acquiring the communication time delay corresponding to the client address and the server address from a pre-established database, and determining the communication time delay as the communication time delay corresponding to the client address of the client.
5. The method according to claim 4, wherein the step of obtaining the communication delay corresponding to the client address and the server address from a pre-established database comprises:
if the communication time delay corresponding to the client address and the server address cannot be obtained from the database, determining a second area range to which the client address belongs;
acquiring communication time delay corresponding to the address of the server and the address of the client in the second area range from the database;
if the communication time delay corresponding to the address of the server and the address of the client in the second area range is not obtained from the database, determining a third area range to which the address of the server belongs;
and acquiring the communication time delay corresponding to the client address in the second area range and the server address in the third area range from the database.
6. The method of claim 2, further comprising:
if the updated historical communication record of the client corresponding to the client address is obtained, extracting the updated communication delay from the updated historical communication record;
and if the updated communication delay is smaller than the communication delay corresponding to the client address recorded in the database, correspondingly storing the updated communication delay and the client address into the database.
7. The method of claim 1, wherein the step of establishing a TCP connection with the client based on the timeout value comprises:
when the timing duration of the timer is less than the timeout value, receiving a response signal returned by the client, and determining that the TCP connection with the client is successfully established;
if the timing duration of the timer reaches the timeout value, no response signal returned by the client is received, and the step of sending a response signal corresponding to the connection request to the client is continuously executed until the response signal returned by the client is received or a preset condition is met;
wherein the preset conditions include: after the connection request is received, the number of times of sending the response signal reaches a preset number threshold, or the current time and the time interval of sending the response signal for the first time meet a preset time threshold.
8. An apparatus for establishing a TCP connection, the apparatus comprising:
the signal sending module is used for sending a response signal corresponding to the connection request to the client if the connection request from the client is received; wherein, the connection request carries the client address of the client;
the time delay acquisition module is used for acquiring the communication time delay corresponding to the client address which is stored in advance;
the timeout value setting module is used for starting a preset timer and setting the timeout value of the timer according to the communication delay;
and the TCP connection module is used for establishing TCP connection with the client based on the timeout value.
9. A server comprising a processor and a memory, the memory storing machine executable instructions executable by the processor, the processor executing the machine executable instructions to implement the method of establishing a TCP connection of any one of claims 1 to 7.
10. A machine-readable storage medium having stored thereon machine-executable instructions which, when invoked and executed by a processor, cause the processor to carry out the method of establishing a TCP connection of any one of claims 1 to 7.
CN202010369814.8A 2020-04-30 2020-04-30 Method, device and server for establishing TCP connection Active CN113596068B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202010369814.8A CN113596068B (en) 2020-04-30 2020-04-30 Method, device and server for establishing TCP connection
PCT/CN2021/083415 WO2021218520A1 (en) 2020-04-30 2021-03-26 Method and apparatus for establishing tcp connection, and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010369814.8A CN113596068B (en) 2020-04-30 2020-04-30 Method, device and server for establishing TCP connection

Publications (2)

Publication Number Publication Date
CN113596068A true CN113596068A (en) 2021-11-02
CN113596068B CN113596068B (en) 2022-06-14

Family

ID=78237760

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010369814.8A Active CN113596068B (en) 2020-04-30 2020-04-30 Method, device and server for establishing TCP connection

Country Status (2)

Country Link
CN (1) CN113596068B (en)
WO (1) WO2021218520A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114039884B (en) * 2021-12-15 2023-08-08 中国建设银行股份有限公司 Network link exception handling method and device
CN115208521B (en) * 2022-08-22 2023-07-04 北京钢铁侠科技有限公司 Communication guarantee and workflow control method for session layer client and server

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070008884A1 (en) * 2003-10-08 2007-01-11 Bob Tang Immediate ready implementation of virtually congestion free guarantedd service capable network
US20090046717A1 (en) * 2007-08-15 2009-02-19 Qing Li Methods to improve transmission control protocol (tcp) performance over large bandwidth long delay links
US20090323543A1 (en) * 2008-06-30 2009-12-31 Canon Kabushiki Kaisha Communication apparatus and method of calculating round trip time
CN102523314A (en) * 2010-12-16 2012-06-27 微软公司 Identifying an efficient destination server
CN102664958A (en) * 2012-04-27 2012-09-12 中山大学 Transparent computing system
CN103763743A (en) * 2012-08-07 2014-04-30 英特尔移动通信有限责任公司 Methods and apparatuses for rate adaptation of quality of service based application
CN104184546A (en) * 2013-05-27 2014-12-03 百度在线网络技术(北京)有限公司 Method and system for reducing message retransmission in mobile communication network
CN104243090A (en) * 2013-06-19 2014-12-24 ***通信集团公司 Sending rate adjustment method and device based on wireless channel feedback
US20150012792A1 (en) * 2013-07-03 2015-01-08 Telefonaktiebolaget L M Ericsson (Publ) Method and apparatus for providing a transmission control protocol minimum retransmission timer
CN104506383A (en) * 2014-12-22 2015-04-08 深圳市博瑞得科技有限公司 Method and system for measuring data processing efficiency of server in TCP (transmission control protocol) transmission
CN105933242A (en) * 2016-04-12 2016-09-07 北京大学深圳研究生院 Method and system for improving TCP response speed of data center
CN106713454A (en) * 2016-12-22 2017-05-24 腾讯科技(深圳)有限公司 Network connection method and device
CN109032830A (en) * 2018-07-25 2018-12-18 广东浪潮大数据研究有限公司 A kind of fault recovery method of distributed memory system, system and associated component
CN110493820A (en) * 2019-09-24 2019-11-22 辰芯科技有限公司 A kind of propagation delay time appraisal procedure, device, communication node and storage medium
CN110839017A (en) * 2019-10-21 2020-02-25 腾讯科技(深圳)有限公司 Proxy IP address identification method, device, electronic equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6816910B1 (en) * 2000-02-17 2004-11-09 Netzentry, Inc. Method and apparatus for limiting network connection resources
JP3931988B2 (en) * 2004-08-26 2007-06-20 日本電気株式会社 Network quality measuring method and measuring apparatus
US7992208B2 (en) * 2005-09-19 2011-08-02 University Of Maryland Detection of nonconforming network traffic flow aggregates for mitigating distributed denial of service attacks
US20070299965A1 (en) * 2006-06-22 2007-12-27 Jason Nieh Management of client perceived page view response time
US20140325064A1 (en) * 2013-04-08 2014-10-30 Telefonaktiebolaget L M Ericsson (Publ) Controlling Establishment of Multiple TCP Connections
CN106034073B (en) * 2015-03-20 2019-01-18 网宿科技股份有限公司 A method of the multi-path transmission optimization based on content distributing network

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070008884A1 (en) * 2003-10-08 2007-01-11 Bob Tang Immediate ready implementation of virtually congestion free guarantedd service capable network
US20090046717A1 (en) * 2007-08-15 2009-02-19 Qing Li Methods to improve transmission control protocol (tcp) performance over large bandwidth long delay links
US20090323543A1 (en) * 2008-06-30 2009-12-31 Canon Kabushiki Kaisha Communication apparatus and method of calculating round trip time
CN102523314A (en) * 2010-12-16 2012-06-27 微软公司 Identifying an efficient destination server
CN102664958A (en) * 2012-04-27 2012-09-12 中山大学 Transparent computing system
CN103763743A (en) * 2012-08-07 2014-04-30 英特尔移动通信有限责任公司 Methods and apparatuses for rate adaptation of quality of service based application
CN104184546A (en) * 2013-05-27 2014-12-03 百度在线网络技术(北京)有限公司 Method and system for reducing message retransmission in mobile communication network
CN104243090A (en) * 2013-06-19 2014-12-24 ***通信集团公司 Sending rate adjustment method and device based on wireless channel feedback
US20150012792A1 (en) * 2013-07-03 2015-01-08 Telefonaktiebolaget L M Ericsson (Publ) Method and apparatus for providing a transmission control protocol minimum retransmission timer
CN104506383A (en) * 2014-12-22 2015-04-08 深圳市博瑞得科技有限公司 Method and system for measuring data processing efficiency of server in TCP (transmission control protocol) transmission
CN105933242A (en) * 2016-04-12 2016-09-07 北京大学深圳研究生院 Method and system for improving TCP response speed of data center
CN106713454A (en) * 2016-12-22 2017-05-24 腾讯科技(深圳)有限公司 Network connection method and device
CN109032830A (en) * 2018-07-25 2018-12-18 广东浪潮大数据研究有限公司 A kind of fault recovery method of distributed memory system, system and associated component
CN110493820A (en) * 2019-09-24 2019-11-22 辰芯科技有限公司 A kind of propagation delay time appraisal procedure, device, communication node and storage medium
CN110839017A (en) * 2019-10-21 2020-02-25 腾讯科技(深圳)有限公司 Proxy IP address identification method, device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
陆摩西: ""SCTP协议关键技术研究及其实现"", 《中国优秀硕士学位论文全文数据库-信息科技辑》 *

Also Published As

Publication number Publication date
WO2021218520A1 (en) 2021-11-04
CN113596068B (en) 2022-06-14

Similar Documents

Publication Publication Date Title
CN113596068B (en) Method, device and server for establishing TCP connection
CN107534930B (en) Recommendation method of Wi-Fi hot spot, terminal and graphical user interface
CN108471369B (en) Network dialing method, device and storage medium
CN106685847B (en) Message processing method, device and equipment
KR101903533B1 (en) Service quality index calculation method and calculation apparatus, and communications system
CN108234087B (en) Data transmission method and sending end
CN110933142A (en) ICFS cluster network card monitoring method, device and equipment and medium
CN113708895B (en) Data transmission method and device and electronic equipment
CN105681385A (en) Information pushing method and device
EP2733905A1 (en) Method, system and devices for managing user registration of a service in an IMS network
CN114301676A (en) Nondestructive asset detection method of power monitoring system
CN112152828B (en) Game acceleration method and device, VPN terminal and storage medium
CN116170870A (en) Network registration method and device, storage medium and electronic equipment
EP3264851A1 (en) Data transmission method and device for data service
CN111818582B (en) Data transmission method and device and electronic equipment
CN107786607B (en) Message retransmission method, message retransmission server and user equipment
CN116599953A (en) File uploading method, device, system, equipment and readable storage medium
CN108307418B (en) Method, device, equipment and medium for identifying LTE weak coverage cell
CN111181890B (en) Method and device for synchronizing signals and server
CN112019391B (en) Terminal network setting method, device, system and storage medium
CN110099001B (en) Bidirectional forwarding detection time parameter negotiation method and device and electronic equipment
CN115438119A (en) Method and device for electing master copy and electronic equipment
CN113852694A (en) Message pushing system and pushing method for multi-terminal access client system
WO2018132966A1 (en) Aging latency detection method, device, data center, and system
CN113542239B (en) Authentication method, system, device and storage medium based on Web monitoring

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
GR01 Patent grant
GR01 Patent grant