zachn

Workaround: macOS WiFi ping spikes

5 posts in this topic

I just picked up a copy of Synergy (used it back in the day but it's been years) and was disappointed by the intermittent latency I was getting. My setup is an ubuntu desktop (server) and a Macbook Pro laptop (client). Both machines are on a reliable WiFi connection. After reading the FAQ and posts by the Apple dev on how the wireless card works it's obvious these 'latency spikes' are due either to shared antenna access or power management features. I assume the power management feature has to be triggered when the time between packets is greater than some unknown threshold. With that in mind I decided to test my assumptions.

# see man page for option descriptions
$ ping -q -n -s 0 -i 0.1 <Synergy_Server_IP>  #That could be any IP on the network really

I'm used to linux so I'm not sure how to get the power management status from MacOS. However, the results are great. I no longer feel the  intermittent 'latency spikes' under normal operating conditions.

  1. Clicking the wifi menu will still result in latency. There's nothing anyone can do about that, the card is scanning channels to find wifi networks so that's just the way it is.
  2. I left bluetooth on for these tests but I didn't have any devices connected.
  3. This approach adds network overhead. The total frame size for our ICMP request is 42 Bytes or 336 bits and the same for our reply. At the rate shown (waiting 100 ms between requests) that's around 10 ICMP requests per second for a total network overhead of 6.72 Kbps. I'm willing to sacrifice that tiny bit of bandwidth for a good Synergy experience.
  4. This approach uses more battery. Since we're tricking the wifi card into not going to sleep you can expect this to have a negative impact on battery life. How much? I have no idea. I mostly use synergy when I'm connected to power.

Perhaps others are already doing this but I hadn't seen mention of it. My tests were a mix of "how does it feel" and actually graphing packets in Wireshark. One test I ran in Wireshark was to capture the time it took to move my mouse after a period of inactivity. Find the first packet the server sent to the client and note it's epoch time. Now wait for a response, In my case I sometimes have to try moving my mouse to the mac a second time. Note the response packet's epoch time. Take the difference and that is the latency you experienced. Run that test again while you run the ping I mentioned above. I now see latencies < 100 ms.

I'm happy to get feedback on this but I mostly just wanted to provide a cludgy solution. Run ping every time you run Synergy. :D

-Zach 

  • Thanks 1

Share this post


Link to post
Share on other sites

I've accidentally noticed that while pinging somewhere the lag was reduced but my knowledge on network stuff is just enough to get by so I dropped that workaround.

Awesome and neat solution.

I'm using a macbook air as server and an imac as client (all conected to an airport router). It's not lagging at all now.

Thank you very much, @zachn!!

  • Like 1

Share this post


Link to post
Share on other sites

Why the hell does this work so well?

Regardless, neat little solution. Fixed my issues right up. I'll put this into a script so I can easily toggle it.

Thanks so much!

  • Like 1

Share this post


Link to post
Share on other sites

@RWAnderson my working theory is that we're preventing the wireless card from going to sleep. I'm glad it has helped you!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now