Latency; Nagle's Algorithm

The network is the forum.

Moderators: Steel, notfred

Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 3:12 am

I'm looking for ways to lower latency on my home network.

In my research I've come across many sites recommending turning off Nagle's Algorithm in Windows 7/8 to decrease latency at the cost of increase bandwidth usage. This involves changing/creating a few registry keys.

In my experience, most "tweaks" offer little to no advantage. Does this tweak offer any real benefit? Or is it something like core parking whose benefits seem mostly placebal?

There are only two users on my network and I have plenty of bandwidth so an increase in traffic isn't a major concern.

In addition, if you have any other suggestions of lowering network latency I'd appreciate any suggestions.
kumori
Gerbil Team Leader
Silver subscriber
 
 
Posts: 282
Joined: Sun Dec 18, 2011 12:11 am

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 5:04 am

I doubt it would do you much good. A well designed program will already turn Nagle's on/off as needed (on *nix by setting TCP_NODELAY on the socket connection).

Nagle's performance depends very much on a program's individual communication patterns i.e. order and size of reads and writes. Forcing it globally on/off on your entire system sounds like a bad idea, and in any case it will only help you if the programs you run are poorly optimised or possibly if the combined network usage patterns of all your running processes is somehow odd.

A program that needs very low latency (like most FPS's maybe) will use UDP, not TCP so Nagle's wont apply anyway.

That said, the only way to be sure is to test it on your own system.
ztrand
Gerbil
 
Posts: 98
Joined: Sat Jun 24, 2006 7:54 am
Location: Europe

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 6:30 am

What NiC are you using? What other hardware do you have running? What kind of network load do you have? Do you have some form of malware, say a bot, on your computer? What is your current latency to where your packets are going and what is your target latency? Is the other computer on your network behaving the same way and getting the same latency? Are you sure you are running full duplex?

I'm asking these questions because there are a number of factors on the network and in software that can cause issues.

And, as ztrand said, don't disable it. It could make things worse. I don't remember how,l but I had bandwidth issues I resolved on Windows 7. Try doing a search for that. My WMC extenders had issues until I turned off some predictive algorithm that Windblowa uses.
Losergamer04
Gerbil Team Leader
 
Posts: 206
Joined: Fri Jan 30, 2009 8:01 am

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 11:06 am

kumori wrote:I'm looking for ways to lower latency on my home network.

In my research I've come across many sites recommending turning off Nagle's Algorithm in Windows 7/8 to decrease latency at the cost of increase bandwidth usage. This involves changing/creating a few registry keys.

In my experience, most "tweaks" offer little to no advantage. Does this tweak offer any real benefit? Or is it something like core parking whose benefits seem mostly placebal?

There are only two users on my network and I have plenty of bandwidth so an increase in traffic isn't a major concern.

In addition, if you have any other suggestions of lowering network latency I'd appreciate any suggestions.


What is your latency now and why do you need to improve it?

--SS
SecretSquirrel
Gerbil Jedi
Gold subscriber
 
 
Posts: 1719
Joined: Tue Jan 01, 2002 7:00 pm
Location: The Colony, TX (Dallas suburb)

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 11:25 am

SecretSquirrel wrote:What is your latency now and why do you need to improve it?
--SS

What he said. I mean, if it's wired, then it's going to be sub-1ms. If it's Wi-fi, only a better router/AP will give you an improvement.
There is a fixed amount of intelligence on the planet, and the population keeps growing :(
morphine
Grand Admiral Gerbil
Silver subscriber
 
 
Posts: 10029
Joined: Fri Dec 27, 2002 8:51 pm
Location: Portugal (that's next to Spain)

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 1:07 pm

kumori wrote:I'm looking for ways to lower latency on my home network.


Use a wire.
Make sure everything is running full duplex.
Use new Cat6 (or higher) cables that aren't hand made.
Get better equipment.
Keep network cables away from appliances and power cables.
Get appliances with better shielding, particularly microwave ovens.
Flatland_Spider
Gerbil Elite
 
Posts: 853
Joined: Mon Sep 13, 2004 8:33 pm
Location: The 918/539

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 1:24 pm

Quick hijack. I'm a dunce when it comes to networking. How do you test network latency?
i5-3570K, ASRock Z77 Pro4-m, Asus GTX660 TOP, 120 GB Vertex 3 Max IOPS, 2 TB Samsung EcoGreen F4, 8GB G-Skill @1.25V, Silverstone PS07B
DPete27
Gerbil Jedi
Silver subscriber
 
 
Posts: 1680
Joined: Wed Jan 26, 2011 12:50 pm
Location: Madison, Wisconsin

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 1:34 pm

DPete27 wrote:Quick hijack. I'm a dunce when it comes to networking. How do you test network latency?
Use ping, but be aware that if you are testing routers out on the Internet they forward traffic in hardware or special software paths and only handle pings on a small management processor. This means that if you ping something like google, and then ping every router along the path, it will look like it takes the packet longer to get half way to google than to go all the way.
notfred
Grand Gerbil Poohbah
 
Posts: 3750
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 10:08 pm

SecretSquirrel wrote:What is your latency now and why do you need to improve it?

--SS


I wanted to improve my latency for voice and gaming. I live in Asia, but tend to play with people in California, so I want to do as much as I can to lower my latency (given the distance). I ran some trace routes and the latency on my end is >1ms (as suggested by other posters) so I guess I'm doing as much as possible?
Last edited by kumori on Thu Jan 30, 2014 11:56 pm, edited 1 time in total.
kumori
Gerbil Team Leader
Silver subscriber
 
 
Posts: 282
Joined: Sun Dec 18, 2011 12:11 am

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 10:21 pm

kumori wrote:I wanted to improve my latency for voice and gaming. I live in Asia, but tend to play with people in California, so I want to do as much as I can to lower my latency (given the distance). I ran some trace routes and the latency on my end is >1m (as suggested by other posters) so I guess I'm doing as much as possible?
So that's a bit like trying to make your flights to and from California take less time by moving a few blocks closer to your airport. Yeah, it makes a difference in theory but compared to the overall trip time...
UberGerbil
Gerbil Khan
 
Posts: 9993
Joined: Thu Jun 19, 2003 3:11 pm

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 10:43 pm

It's quite possible to lower your latency with certain VPN services depending on where the game server is and where the vpn tunnel exits.


Just an example. http://www.smoothping.com/


That is the one 2 of my friends in Asia use to play WoW here in the states.Works very well for them.Just need to make sure you choose the smoothping server near your game server.


Edit* It also depends on how bad your normal route is to your game server. In the case of my friends,it shaves 100ms + off their ping.

Here is a link to ping all their exit servers.Id be interested for you to share your results to the exit server nearest to the same server you wish to play on.

edit2* Thinking more on it,connecting to LA(possibly) as your entry point from Asia, to the US would be best i would think.

http://www.smoothping.com/pingtest
panthal01
Gerbil In Training
 
Posts: 5
Joined: Sat Dec 10, 2011 11:02 pm

Re: Latency; Nagle's Algorithm

Postposted on Thu Jan 30, 2014 11:18 pm

kumori wrote:
SecretSquirrel wrote:What is your latency now and why do you need to improve it?

--SS


I wanted to improve my latency for voice and gaming. I live in Asia, but tend to play with people in California, so I want to do as much as I can to lower my latency (given the distance). I ran some trace routes and the latency on my end is >1m (as suggested by other posters) so I guess I'm doing as much as possible?


1m is 1minute?

Ping your firewall/router. One to two miliseconds is quite normal for a home router/firewall over a wired connection. Now for some math. The great circle distance from Hong Kong to San Fransisco (Asia to California) is 11147 km. If you were to run a single optical fiber between those two citys in the most direct path possible, there would be a 55ms delay for a signal traveling one way. So for a round trip ping, physics says your time will be 110ms at a theoretical minimum.

For me, in Texas, a ping to a Hong Kong IP address is about 218ms. 160ms of that is physics. That leaves 58ms. 12ms is the hop from my router to my ISP gateway. Down to 46ms. That is mainly composed on hops across the US. My internal network contribution? 1.04ms. Everything else is out of my control.

All that said, depending on what you are doing, disabling Nagle's algorithm (TCP_NO_DELAY) might actually help depending on the the application, especially since the long path delay can have a similar effect as TCP delayed acknowledgedment (again, depending on the application). One other thing to consider. None of this matters if the application uses UDP for communications. Also, TCP_NO_DELAY is usually set at the connection level by the application if it will benefit from it.

--SS
SecretSquirrel
Gerbil Jedi
Gold subscriber
 
 
Posts: 1719
Joined: Tue Jan 01, 2002 7:00 pm
Location: The Colony, TX (Dallas suburb)

Re: Latency; Nagle's Algorithm

Postposted on Fri Jan 31, 2014 8:48 am

DPete27 wrote:Quick hijack. I'm a dunce when it comes to networking. How do you test network latency?


Iperf is option if you can run it on both ends, but usually ping is the way to check latency. Then there is mtr (mytraceroute) which might be able to tell you which hop is misbehaving.
Flatland_Spider
Gerbil Elite
 
Posts: 853
Joined: Mon Sep 13, 2004 8:33 pm
Location: The 918/539

Re: Latency; Nagle's Algorithm

Postposted on Fri Jan 31, 2014 9:19 am

iperf is a bandwidth tester rather than latency.
notfred
Grand Gerbil Poohbah
 
Posts: 3750
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

Re: Latency; Nagle's Algorithm

Postposted on Fri Jan 31, 2014 10:22 am

kumori wrote:
SecretSquirrel wrote:What is your latency now and why do you need to improve it?

--SS

I wanted to improve my latency for voice and gaming. I live in Asia, but tend to play with people in California, so I want to do as much as I can to lower my latency (given the distance). I ran some trace routes and the latency on my end is >1ms (as suggested by other posters) so I guess I'm doing as much as possible?

Nothing you can do at the LAN level will make a damn bit of difference in this case. Asia to Cali is going to have a ton of latency simply due to the time it takes the electrical signal to get there and back (at the speed of light). Shaving a few microseconds off of something that is already up in the 10s of milliseconds is pointless. Latency-critical voice and gaming applications will generally use UDP anyway*, so disabling Nagle's algorithm won't have any effect; all you'll probably accomplish is slowing down web browsing and other non-real-time usage.

*TCP stinks for real-time applications because a dropped packet will stall the connection until the retransmission takes place. In situations where it is more important to keep the packets flowing than to ensure that every packet gets there (gaming and VOIP being two notable examples!), developers with a clue will use UDP instead (or maybe even raw Ethernet, if the traffic does not need to leave the local network and the application has access to the network stack).
(this space intentionally left blank)
just brew it!
Administrator
Gold subscriber
 
 
Posts: 37854
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Latency; Nagle's Algorithm

Postposted on Fri Jan 31, 2014 11:06 am

just brew it! wrote:Nothing you can do at the LAN level will make a damn bit of difference in this case

What he said.

Well, other than using wired networking instead of Wi-Fi, which is pretty much the only thing that can be done.
There is a fixed amount of intelligence on the planet, and the population keeps growing :(
morphine
Grand Admiral Gerbil
Silver subscriber
 
 
Posts: 10029
Joined: Fri Dec 27, 2002 8:51 pm
Location: Portugal (that's next to Spain)


Return to Networking

Who is online

Users browsing this forum: No registered users and 3 guests