What determines the number of data packets before sending an ACK? .NET sockets on the server

What determines how many data packets are sent / received by the client before the client sends the ACK? Is there a way to configure this either on the server side or on the client side to send more data before the ACK? How long does the server continue to send packets if the ACK is not received? Is this customizable? Does the server request an ACK or is the client just sending them?

Thanks,

Sam

+4
source share
1 answer

Each byte sent over a TCP connection requires confirmation. These are the rules. The server does not explicitly request an ACK, because it does not need it - it just expects you to play by the rules, and when it sends the data, you will confirm it. If you do not send the ACK for more than a certain number of bytes, any of three things can happen: the server will wait for a while for the ACK (read: dead air), resend all data that you did not confirm (read: more network traffic), or if he tried and could not do it, he will reset the connection (read: "Connection reset by peer nodes").

With all that, you do not need to immediately select each package. The server will send a certain number of bytes, which will be no more, and, as a rule, will be less than the "receive window" declared by the client - before it needs an ACK. You can wait and collect several segments, and immediately run them if you want ... or send them with the data that you send to the server. (ACKs with data are virtually free.) Windows does this already ; he waits about 200 ms after he receives the segment before he sends the ACK. If another segment arrives at this time, or if Windows has data ready to send, the ACK is sent immediately, which covers both segments. The effect is that in the general case (a collection of data arriving simultaneously), the number of bare ACKs is halved.

If you really think you can do better than this, there seems to be a registry setting for TcpAckFrequency , which is the "number of TCP confirmations that will be issued before the delayed ACK timer is ignored" (read: before Windows sends the ACK immediately). The default value is 2. You can increase this if you want, but you run the risk of causing delays if it is too high.

There is also TcpDelAckTicks , which determines how long the delay is (ticks in 100 milliseconds). By default, it is 2. Again, if it is too high, you can cause delays that slow down your network when crawling.

If you insist on trying it, check out HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces . It has several keys with GUID names; one matches your current network connection. (If you are on a Wi-Fi network, there are also subsections - one for each network?) You will need to add values ​​there - they do not exist by default.

Also, see http://download.microsoft.com/download/c/2/6/c26893a6-46c7-4b5c-b287-830216597340/TCPIP_Reg.doc . It tells you about the various options that you can set. Note that many value names do not currently exist in the registry! You will need to add them to install them.

+9
source

Source: https://habr.com/ru/post/1400334/


All Articles