Ping on Mavericks on late 2013 MacBook Pro slow and variable compared to Windows

I had a couple of issues connecting to an SMB share last night so started using ping to test connectivity.

At that point I noticed the ping was very slow and variable - my Windows laptop shows <1ms for all pings to the router.

An example:

64 bytes from 192.168.1.1: icmp_seq=335 ttl=64 time=208.350 ms
64 bytes from 192.168.1.1: icmp_seq=336 ttl=64 time=129.768 ms
64 bytes from 192.168.1.1: icmp_seq=337 ttl=64 time=51.067 ms
64 bytes from 192.168.1.1: icmp_seq=338 ttl=64 time=278.491 ms
64 bytes from 192.168.1.1: icmp_seq=339 ttl=64 time=1.315 ms
64 bytes from 192.168.1.1: icmp_seq=340 ttl=64 time=120.040 ms
64 bytes from 192.168.1.1: icmp_seq=341 ttl=64 time=40.420 ms
64 bytes from 192.168.1.1: icmp_seq=342 ttl=64 time=267.817 ms
64 bytes from 192.168.1.1: icmp_seq=343 ttl=64 time=188.607 ms
64 bytes from 192.168.1.1: icmp_seq=344 ttl=64 time=109.445 ms
64 bytes from 192.168.1.1: icmp_seq=345 ttl=64 time=1.313 ms
64 bytes from 192.168.1.1: icmp_seq=346 ttl=64 time=1.905 ms
64 bytes from 192.168.1.1: icmp_seq=347 ttl=64 time=3.662 ms
64 bytes from 192.168.1.1: icmp_seq=348 ttl=64 time=100.708 ms
64 bytes from 192.168.1.1: icmp_seq=349 ttl=64 time=21.266 ms
64 bytes from 192.168.1.1: icmp_seq=350 ttl=64 time=1.674 ms
64 bytes from 192.168.1.1: icmp_seq=351 ttl=64 time=1.397 ms
64 bytes from 192.168.1.1: icmp_seq=352 ttl=64 time=89.599 ms
64 bytes from 192.168.1.1: icmp_seq=353 ttl=64 time=10.996 ms
64 bytes from 192.168.1.1: icmp_seq=354 ttl=64 time=341.583 ms
64 bytes from 192.168.1.1: icmp_seq=355 ttl=64 time=159.329 ms
64 bytes from 192.168.1.1: icmp_seq=356 ttl=64 time=81.145 ms
64 bytes from 192.168.1.1: icmp_seq=357 ttl=64 time=1.945 ms

I have not seen any other symptoms - network speeds and things like ping test are fine. I see similar behaviour when pinging external sites though - much slower and variable.

I have tried plugging into power (possibly power saving could cause this) and also restarting.

I searched before posting and found no other questions, but now one of the related questions is useful - changing the interval to 200ms makes the pings fast and consistent.

But why would changing the ping interval to be 200ms instead of 1s change the latency?


Solution 1:

The ping on Mavericks is badly broken. The reason for this is Mavericks puts network card into a power save mode within milliseconds when there's no traffic that it considers vital, and apparently it doesn't consider pings to be valuable traffic, therefore the network card (or, rather, wifi card) goes to "sleep" immediately, and it takes time for it to do so, therefore causing completely random ping results.

I have submitted a bug report to Apple in the early beta stages of the Mavericks, but they refused to address the issue, claiming "will not fix".

So the results you're seeing are not representative of the actual network connection.

Solution 2:

Try running the following command if you need low latency for something like online gaming. It continuously pings your router every 200ms to stop the new 802.11ac Broadcom chip in the 2013 Haswell Macs from ever going to sleep.

ping -i 0.2 `netstat -nr | grep -m 1 '^default' | awk '{print $2;}'`

Hopefully, Apple will provide a proper fix for this in the coming Mac OS 10.9.2 update. They really screwed up on this one.