Avoid the delay caused by ack validation mechanism by modifying the Registry

Source: Internet
Author: User

TCP is a link-oriented communication protocol. Each sending and receiving action of both parties must be based on the normal communication link. Therefore, TCP provides the default ack authentication mechanism.

Assume that there is a TCP communication link between A and B. At a time point, a sends data to B for the first time, and B does not send data to a for the first time. After about ms, B will automatically send an ACK confirmation packet with a length of 1 to A, which is determined by the default mechanism of TCP, and before a receives the ACK confirmation packet, it is not allowed to send data to B for the second time, so when B receives the data for the second time, it will produce a latency of about MS-This latency is not anything else, it is the default sending latency of the ACK Validation Package.

When we test our self-developed server-side communication framework, once it is broadcast, at this time, the client in the receiver is likely to cause the above phenomenon due to uneven sending and receiving of both parties-this is not because your server communication framework performance is not up to standard, it is caused by the internal mechanism of TCP.

So how should we avoid this situation? Here we will introduce the simplest and easiest way to achieve this: Modify the Registry to increase the default sending frequency of the ACK package on the client, that is, to shorten the sending latency of the ACK package:

First, click the "Start" menu in the lower left corner of your computer screen, open "run", and type "Regedit" to open your registry;
Select the HKEY_LOCAL_MACHINE project to start from the next point,
HKEY_LOCAL_MACHINE/system/CurrentControlSet/services/TCPIP/parameters/interfaces/
Here is the data about your Nic, there are many items, and they all have names like {B796DCA-FFE8-4002-A28F-4D2B57AE8383, however, the correct one will display network settings in the right window, including your IP address and your server IP address ). If you find the dhcpipaddress that matches your local IP address, it is the setting of the NIC that connects you to the Internet, the goal of our task is to modify it to increase the sending frequency of the client ack package.

Next, right-click the blank area on the right of the window and choose "New"> "DWORD Value ";
Rename it "tcpackfrequency", right-click it, select "modify", and then fill in "1" in the blank space of "value data" (do not worry about hexadecimal format, or 10 hexadecimal)

Finally, close the registry, restart the computer, and complete the modification.

Note: The XP client can directly achieve the goal through the above operations. For win2003server, you need to install a patch file in advance. This file can be downloaded on your own resource page, with a score of 0. In addition, the client accessing the Internet via proxy is invalid.

Disadvantages: the client is irrelevant, but it increases the burden on the server.

Recommendation: This method can be used to greatly improve the card playing phenomenon during online games.

Additional instructions on tcpackfrequency:

The value of tcpackfrequency determines the valueFrequencyThat is, several packets will be waiting before sending the "correct command response;
The default value is 2. At this time, the TCP/IP sends a response after receiving two segments, or send a response when one segment is received but no other segment is received within 200 milliseconds
If the value is 3, the TCP/IP sends a response after receiving three segments, or send a response when one or two segments are received but no other segments are received within 200 milliseconds, and so on.
If you want to shorten the response time by eliminating TCP/IP response latency, set this value to 1. In this case, Windows returns a "correct command response" every time a TCP packet is received ".

The valid range of this value is 0 to 255. 0 indicates that the default value is used (2 ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.