• Jul 17, 2018, 05:53 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Reducing Ping on TCP based games  (Read 4413 times)

Baya

  • Administrator
  • Karma: +5/-3
  • Posts: 316
Reducing Ping on TCP based games
« on: Sep 27, 2011, 09:12 PM »

Note: If you have a real firewall (linux based programmable hardware, not a consumer grade netgear router or a software firewall) you should use iptables to do this. (You can also do it in an ultra-lightweight virtual machine if you know what you're doing.) The following is for Windows users that want an easier less cantankerous solution.

This will reduce the latency for TCP/IP games (Aion, WoW, CO, etc.) by not using delayed acknowledgments (ACKs) as specified in RFC 1122. It is on by default because it optimizes the transfer of packets by preferring to send ACKs only when full-sized TCP data packets (or a bunch of small packets -- segments -- that add up to a complete packet) arrive, thereby reducing overall bandwidth. Since TCP/IP games generally use (much) less than complete packets to transmit data, Windows is imposing a 200ms delay waiting for a packet to complete (which it never will, because the game server is waiting for an ACK before sending the next packet) before sending an ACK.

On the other end of the pipe, the server is using the Nagle algorithm which means that it is buffering data until it receives an ACK or until it has a full data packet to send.

So what ends up happening is something like this:

  0ms Server sends segment, waits for an ACK.
 20ms Client receives segment, waits for more data before sending ACK.
 50ms Server buffers segment.
100ms Server buffers segment.
150ms Server buffers segment.
200ms Server buffers segment.
220ms Client sends ACK.
240ms Server receives ACK, sends buffered segments, waits for ACK.
250ms Server buffers segment.
260ms Client receives segment, waits for more data before sending ACK.
... etc.


It's actually more complicated than that because the server will occasionally generate full TCP data packets while waiting for an ACK and send those along, and when it does that, since the client receives two segments, it will immediately ACK, but then you go back to the beginning where the server sends a segment having received an ACK and then sits in a wait buffering state again.

This is exactly what services like Lowerping and Gamepath do for you remotely -- they ACK the server as soon as any segment comes in, telling it to send the next segment immediately. Your computer ACKs faster using one of these services because the packet stream never pauses, so your comp is getting full data packets faster.

Why is it like this? TCP/IP was never designed for real time applications or for small data segments. It has a 20 byte TCP header and a 20 byte IPv4 header meaning that if you want to send 1 byte of data, it costs you 41 bytes to do it in TCP. The imposed waits are so that the packets are as full as they can be when transmitted, thereby lowering the overhead of the headers and helping to prevent congestion.

Should you do this? Up to you. It will make large file transfers less efficient. (More upstream bandwidth on your end to download porn since you're ACK'ing every single packet.) Your machine will (technically) be out of compliance with current TCP/IP standards. You probably won't notice a thing outside of TCP/IP games in daily usage.

Notes:
  • Capitalization matters.
  • You have to have the latest service packs installed.
  • This will have absolutely no effect on UDP based games. (Pretty much every other game in the world, including EQ2.)

More on:

Undoing it:
Follow the same steps, but change TcpAckFrequency to 2 and TCPNoDelay to 0.


Windows Vista/7

 1. Run "regedit" (Start -> Search -> regedit)
 2. Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces
 3. Browse the items under interfaces until you find one that has an IP Address entry matching the network interface you want to affect (typically LAN IP addresses start with 192.168 or 10.0); note that if your IP address is automatically assigned by a DHCP server you may need to look for a matching DhcpIPAddress instead of IPAddress
 4. Right-click on the interface and select New > DWORD (32-bit) Value, name it TcpAckFrequency
 5. Right-click the new TcpAckFrequency value and select Modify, enter 1 (Hexadecimal radio button should be selected)
 6. Right-click on the interface and select New > DWORD (32-bit) Value, name it TCPNoDelay
 7. Right-click the new TCPNoDelay value and select Modify, enter 1 (Hexadecimal radio button should be selected)
 8. Exit regedit and reboot.


Windows XP

 1. Run "regedit" (Start -> run... -> regedit)
 2. Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\
 3. Browse the items under interfaces until you find one that has an IP Address entry matching the network interface you want to affect (typically LAN IP addresses start with 192.168 or 10.0); note that if your IP address is automatically assigned by a DHCP server you may need to look for a matching DhcpIPAddress instead of IPAddress
 4. Right-click on the interface and select New > DWORD Value, name it TcpAckFrequency
 5. Right-click the new TcpAckFrequency value and select Modify, enter 1 (Hexadecimal radio button should be selected)
 6. Browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ\Parameters
 6a. If you don't have a registry entry for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ\, navigate back to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\
 7. Right-click on the right-hand pane and select New > DWORD Value, name it TCPNoDelay
 8. Right-click the new TCPNoDelay value and select Modify, enter 1 (Hexadecimal radio button should be selected)
 9. Exit regedit and reboot.
Logged
A good plan violently executed now is better than a perfect plan executed next week.

It doesn't matter how many dragons you kill. All that matters is who takes home the princess.
 


solitude-cats
solitude-cats
solitude-cats
solitude-cats