0

For my research, I need to have two devices sync to each other with very low delay (<1 ms). I understand that when they are connected to the same wifi router, they will get a different private IP address assigned by the router. Ideally, the ping between devices under the same local network should be very low. Unless I misunderstand something here.

In my experiment, I disconnected the router from the internet (unplugged the cable from the wall) and used one device to ping the router and the other device. The names and the IP addresses of the devices are:

the router: 192.168.1.254 device1: 192.168.1.122 device2: 192.168.1.154

The latency time are not what I expected: ping between the router and device1: image1; ping between device1 and device2: image2. I am expecting the time to be within 1 ms, which is not the case here. All devices are present in the same room and within 3 meters, so I don't think the connection is the issue here.

I am not sure how to fix this high latency. It is possible that I might misunderstand a few concepts here. Any help would be greatly appreciated.

0

3 Answers 3

0

If you want to reduce latency you might want to remove the router from the communication.

Use an ad-hoc wireless network and you should see pings well below 1ms.

The nodes discover each other and communicate directly and that makes it a lot faster. Of course you should also choose the right channel (and location) because, since it is a radio link, other nodes in the same frecuencies could create interference and slow you down.

This tutorial for Debian show times below 0.07 ms. I know it's not your system, but it is still a good reference. This page explains how to do it in some version of Windows.

4
  • I will essentially be using 4 raspberry Pis that run on Debian. Is it true that having the router as the center of the communication will always cause high latency because it adds one more node? Can you provide some clarification?
    – Yihan Hu
    Jun 17, 2020 at 18:11
  • No, not always and not because of the router being an extra hop. It's more about the induced latency in the router (time to process each piece of information). If you want, you can comunicate in the most basic and insecure way in ad-hoc. That's fast. When you add encryption/decryption for example, it happens four times (A->router then router->B, then back). You can surely configure an ad-hoc network that performs worse than the infrastructure one (a big mesh for example). No silver bullets here, but in your current setup, if you cannot run a cable, ad-hoc might help. Jun 17, 2020 at 18:37
  • Thank you. I will try out this method. One extra question, it is not right to say devices under the same network will have very low latency, correct?
    – Yihan Hu
    Jun 18, 2020 at 3:11
  • I wouldn't say it. Network does not mean the same thing for everybody. And there are a lot of them, each with it's own properties. Are each NASA's Deep Space Network stations and a Mars rover in the same network (segment)? The ping roundtrip would take between 9 and 42 minutes... Jun 18, 2020 at 3:51
0

If you want low latency, use a wired connection.

Compare the following two ping test from my desktop to other devices on my network at home.

The first is from my desktop to my home server, which are both wired:

C:\Users\micha>ping 192.168.20.140

Pinging 192.168.20.140 with 32 bytes of data:
Reply from 192.168.20.140: bytes=32 time<1ms TTL=64
Reply from 192.168.20.140: bytes=32 time<1ms TTL=64
Reply from 192.168.20.140: bytes=32 time<1ms TTL=64
Reply from 192.168.20.140: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.20.140:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

The second one, is from my desktop to my mobile phone, which is on a wireless connection:

C:\Users\micha>ping 192.168.20.168

Pinging 192.168.20.168 with 32 bytes of data:
Reply from 192.168.20.168: bytes=32 time=57ms TTL=64
Reply from 192.168.20.168: bytes=32 time=4ms TTL=64
Reply from 192.168.20.168: bytes=32 time=200ms TTL=64
Reply from 192.168.20.168: bytes=32 time=113ms TTL=64

Ping statistics for 192.168.20.168:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 4ms, Maximum = 200ms, Average = 93ms

You can see that having half of the connection spanning WiFi significantly increases the ping time, even though all three devices are within one metre of each other.

2
  • I understand that the wired connection is definitely much better than wireless. But it is ideal in my research that all devices are connected through wireless wifi. Is there any other way that i can reduce the latency?
    – Yihan Hu
    Jun 17, 2020 at 18:08
  • The only way I can think of, that might work, would be to have multiple wireless endpoints that are dedicated to each device. That way, they aren't waiting their turn while another device is communicating with the AP. Jun 18, 2020 at 0:19
0

Wired latency would be less than 1 millisecond. However WiFi is expected to be higher. It can be 10x to 100x higher in some cases. WiFi is also finicky, in that small variable can have a big difference. You can try switching Wifi channels, moving antennas, or even replacing antennas with high gain ones.

If you need low latency, you need to go with wired ethernet, for the best performance.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .