Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure socket ACK timeout?

Is there a way to configure the timeout in which a socket expects to receive an ACK for sent data before it decides that the connection has failed?

I'm aware this can be done at the application level as well, but since every packet I send is ACK'd anyway, and I just want to know if my data is received, using additional data at the application level to accomplish the same thing seems wasteful. (Not to mention, my particular application uses per-byte charged cellular links.)

Note: As per my previous question -- What conditions cause NetworkStream.Write to block? -- you cannot rely on .Write throwing an exception in order to determine that data is not being sent properly.

like image 807
David Pfeffer Avatar asked Oct 05 '11 20:10

David Pfeffer


People also ask

How do I set socket timeout?

Answer: Just set the SO_TIMEOUT on your Java Socket, as shown in the following sample code: String serverName = "localhost"; int port = 8080; // set the socket SO timeout to 10 seconds Socket socket = openSocket(serverName, port); socket. setSoTimeout(10*1000);

What is ACK timeout?

Definitions. ACK Timeout = Air Propagation Time (max) + SIFS + Time to transmit 14 byte ACK frame [14 * 8 / bitrate in Mbps] + Air Propagation Time (max)

How do I disable TCP delayed ACK?

To disable Delayed ACKs, use the TCP_QUICKACK socket option. Enabling the TCP_NODELAY option turns Nagle's algorithm off.

What is timeout in socket?

socket timeout — a maximum time of inactivity between two data packets when exchanging data with a server.


1 Answers

There is mention of a "user timeout" in some IETF RFCs (5482 793) which does what is being asked for.

Some other operating systems support this as a socket option but not Windows unfortunately.

Without this option, the only ways to reduce the time until abort in this scenario would be to reduce the number of retransmission attempts, or reduce the initial RTT.

On Windows the former can be controlled (machine wide..) via netsh/registry: Tcp Max Data Retransmissions.

Is it feasible to just abandon the current connection via your own timeout, and make another if required?

  • The applications would have to establish when the connection is to be abandoned - possibly some "time to live" established at the start of the TCP conversation, based on time of inactivity or effective data rate
  • There would a bit of data overhead due to the retransmits from the old connection
  • The server app may need changed to accept more than one concurrent conection
  • This process should not be repeated indefinately by the client in case the network never achieves quite enough speed for your timeout
like image 141
Peter Wishart Avatar answered Sep 22 '22 19:09

Peter Wishart