Jump to content

Workaround: macOS WiFi ping spikes


zachn

Recommended Posts

Posted

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 

  • Nick Bolton pinned this topic
  • 3 weeks later...
Posted

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!!

  • Nick Bolton unpinned this topic
Posted

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!

Posted

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

  • 4 weeks later...
Chekhov's Chainsaw
Posted

You know, I was just going to post a new issue as it seemed that with TLS on, that my Mac had experienced a lot of new latency and jitter after updating to Mojave 10.14.1 ... but your solution makes Synergy run like butter, so no matter.

Apple must have tweaked the power management stuff a bit more in the latest release. (Writing these details here for future seekers)

 

Followup thought: I changed my -i interval to 1s instead of .1 to reduce the overhead. Seems to work every bit as good.

Another thought: This would be trivial to include as an option in Synergy, would it not? I'm thinking like a checkbox that reads "Continually poll the server (reduces mouse latency as a result of certain power-saving features)".  Since the client knows the IP/Hostname of the host, just throw a packet at the host every N ms.

  • 2 months later...
Posted

Had the same issue and this does indeed work. I noticed that it was also in my case on a 2018 macbook pro, tied in someway to the battery %, so that must be some sort of condition in their setup for the wifi on/off.

  • 3 months later...
Posted

Setup between Win10 (server) and OSX (client). Didn't get Synergy 1 to work properly, same network, allowed in firewall on both OSes and also in the router. Pings went trough without problems.

Really needed this to work to actually utilize the 49" monitor I just got.

Took a gamble with Synergy 2, experienced lot of lag and DC from the client. Installed Share-Mouse. Proved itself being 200 times worse.

Was just about to give up, at least for now but then i tried this. Decreases lag and keeps the connection alive (still have some DC issues) however seems to work pretty well when using the Mac for longer periods.

Basically, I just wanted to say thank you @zachn

  • Kelvin Tran unpinned this topic

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...