0

I have struggled with API of https://api.materialsproject.org recently. Because it is so slow and unstable when fetching data. I thought it was just the problem of this site. However, I found it is not true today.

I always work on my laptop which is connected to a wifi router. I just happened to try another computer with an ethernet connection, and I found it fetches data fast!

So I made a ping test on my laptop.

Disable wifi and insert the network cable, I got

PING api.materialsproject.org (104.18.41.120) 56(84) bytes of data.
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=1 ttl=54 time=136 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=2 ttl=54 time=134 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=3 ttl=54 time=137 ms

remove cable, and insert the same cable into wifi router, and connect laptop to this wifi router, I got

PING api.materialsproject.org (104.18.41.120) 56(84) bytes of data.
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=4 ttl=44 time=303 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=6 ttl=44 time=301 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=9 ttl=44 time=301 ms

Wow, this is really impressive, an immediate 200ms delay. To rule out the possibility that I may have a bad wifi, I tried another wifi router, still 300ms!

This really perplexed me, because my wifi is actually very fast tested by https://www.speedtest.net, which gives

enter image description here

An even weirder thing is that my work place has an AP network. If I connect to this AP network, I got a fast ping

PING api.materialsproject.org (104.18.41.120) 56(84) bytes of data.
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=1 ttl=54 time=134 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=2 ttl=54 time=135 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=3 ttl=54 time=135 ms

However, according to speedtest, this AP network is much slower!

enter image description here

Can somebody explain what is going on? Is there a way to decrease my ping time to api.materialsproject.org via wifi connection?


PS:

As suggested by Martin, I ping the gateway, and I got

Pinging 192.168.31.1 with 32 bytes of data:
Reply from 192.168.31.1: bytes=32 time=1ms TTL=64
Reply from 192.168.31.1: bytes=32 time=2ms TTL=64
Reply from 192.168.31.1: bytes=32 time=2ms TTL=64
Reply from 192.168.31.1: bytes=32 time=3ms TTL=64

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

As suggested by petitradisgris, I run tracert api.materialsproject.org when connected to wifi and got

Tracing route to api.materialsproject.org [104.18.41.120]
over a maximum of 30 hops:

  1     3 ms     2 ms     1 ms  XiaoQiang [192.168.31.1]
  2     3 ms     3 ms     3 ms  172.16.24.1
  3     6 ms     6 ms     3 ms  120.199.21.1
  4     5 ms     5 ms     5 ms  221.131.254.53
  5     *        *        *     Request timed out.
  6     *        7 ms     6 ms  111.24.10.169
  7    28 ms    28 ms    29 ms  221.183.118.37
  8    32 ms    28 ms    28 ms  111.24.17.161
  9    32 ms    35 ms    34 ms  221.176.21.190
 10    33 ms    37 ms    34 ms  221.183.25.202
 11    33 ms    54 ms    32 ms  221.183.55.109
 12   203 ms   204 ms   204 ms  223.120.12.213
 13   218 ms   217 ms   217 ms  223.120.6.218
 14   362 ms   368 ms   364 ms  223.119.64.110
 15   307 ms   316 ms   306 ms  172.70.212.2
 16     *      309 ms     *     104.18.41.120
 17   301 ms     *      301 ms  104.18.41.120

Trace complete.

Then I run tracert api.materialsproject.org with only cable connected

Tracing route to api.materialsproject.org [104.18.41.120]
over a maximum of 30 hops:

  1     2 ms     2 ms    <1 ms  172.16.24.1
  2    27 ms     7 ms     6 ms  61.153.0.129
  3     *        *        *     Request timed out.
  4     *        *        2 ms  115.233.18.21
  5     *        *        4 ms  202.97.101.189
  6     7 ms     7 ms     7 ms  202.97.64.182
  7     *        7 ms     7 ms  202.97.50.193
  8   142 ms   146 ms   143 ms  202.97.71.198
  9   209 ms   267 ms   220 ms  218.30.53.214
 10   168 ms   157 ms   158 ms  172.68.188.22
 11   135 ms   135 ms   134 ms  104.18.41.120

Trace complete.

PS

Now I came back home. I can test yet on another wifi router, and this one is expensive :)

Surprisingly, the ping also takes 300ms. Trace are below

Tracing route to api.materialsproject.org [104.18.41.120]
over a maximum of 30 hops:

  1     1 ms    10 ms    <1 ms  RT-AX86U-0158 [192.168.50.1]
  2     2 ms     1 ms     1 ms  SMBSHARE [192.168.1.1]
  3     6 ms     4 ms     4 ms  10.109.128.1
  4     5 ms     4 ms     6 ms  221.131.254.41
  5     *        *        *     Request timed out.
  6     6 ms     6 ms     7 ms  111.24.10.169
  7    28 ms    28 ms    28 ms  221.183.118.33
  8    31 ms    52 ms    30 ms  111.24.2.250
  9    29 ms    28 ms    28 ms  221.176.21.190
 10    28 ms    28 ms    27 ms  221.183.52.1
 11    36 ms    38 ms    41 ms  221.183.55.109
 12   206 ms   208 ms   212 ms  223.120.12.213
 13   202 ms   207 ms   209 ms  223.120.6.218
 14   445 ms   459 ms   450 ms  223.119.64.110
 15   317 ms   318 ms     *     141.101.72.32
 16   323 ms     *        *     104.18.41.120
 17     *        *        *     Request timed out.
 18     *        *        *     Request timed out.
 19   312 ms   305 ms   313 ms  104.18.41.120

Trace complete.

Still takes a complicated route. So I came up another question. Since we already know there is a shortcut to the server, is it possible to force wifi to take the best route?

user15964
  • 121
  • 6
  • It could be a good idea to run the ping to api. parallel to a ping to your local router's IP - this way, you are able to see how much of the 300ms really comes from the wifi connection... – Martin Jun 14 '22 at 12:27
  • You could also try to ping the first "Hop" in the other side of your ethernet Wire. Or a traceroute,if it is not pingable. Like that, you compare the latency to this hop between a direct ethernet connection and via the Wifi router between them. – petitradisgris Jun 14 '22 at 12:30
  • @Martin How to do it? Sorry, I am not good at networking things :) – user15964 Jun 14 '22 at 12:31
  • @petitradisgris Thank you. But again how to do it? :) I do not understand – user15964 Jun 14 '22 at 12:32
  • on windows, run ipconfig inside a command prompt window, find the line which says "Default Gateway" - that is the IP you want to ping... – Martin Jun 14 '22 at 12:39
  • @user15964 . On a Windows CMD prompt: >tracert api.materialsproject.org. On a Linux shell prompt: $traceroute api.materialsproject.org. – petitradisgris Jun 14 '22 at 12:40
  • @petitradisgris I run your suggestions and updated my post :) – user15964 Jun 14 '22 at 12:47
  • @user15964 . May you show us 2 tracert: one when you are directly connected to the ethernet link, and an other one when you are connected via the wifi router? – petitradisgris Jun 14 '22 at 12:50
  • @petitradisgris I updated my post – user15964 Jun 14 '22 at 13:03
  • Those are two very different routes. I would expect them to have very different performance results. – Greg Askew Jun 14 '22 at 13:05
  • @GregAskew Ok~ but why does it take a different route? Does wifi router deserve a bad route : ) – user15964 Jun 14 '22 at 13:08
  • please check your router... The IP 120.199.21.1 belongs to "China Mobile Communications Cooperation" - I think your WiFi router is routing traffic via a cellular network! (LTE for example...) - or maybe it is an included VPN inside the router, which redirects all traffic through it... – Martin Jun 14 '22 at 13:14
  • @Martin Well, China Mobile is a big company. They happens to have "mobile" in their company's name, that does not means they only do mobile things : ) I am sure my wifi router won't routing via cellular network, that is wired for wifi router ... – user15964 Jun 14 '22 at 13:19
  • But one thing you can be sure of: your wifi router is doing some weird things, otherwise the traceroute wouldn't look that different – Martin Jun 14 '22 at 13:26
  • Try to redo 1 or 2 times a traceroute (wait 5 minutes). I just wanna be sure that the differences we see is not linked to the internet backbone internal routing modifications, and that your routes stay "more or less" static accross time. But i agree with @martin. You'r router seems to do some VPN stuff toward somewhere – petitradisgris Jun 14 '22 at 13:27
  • It could also be caused by a Windows 10 "feature" or VPN functionality depending on, if the local network is trusted or not – petitradisgris Jun 14 '22 at 13:30
  • @petitradisgris I do it on another wifi router. See my update – user15964 Jun 14 '22 at 13:57
  • @user15964 . I tried to answer something ahah. In all case: its your ISP China -> HongKong link which seems bad, and there is nothing you can do about it... However, you may set-up a VPN connection to an open and free VPN server near you and see if your link speed would be improved. – petitradisgris Jun 14 '22 at 14:51

4 Answers4

4

If you drive straight to work and back it'll take one amount of time, if you go via Starbucks and McD's on the way there and back it'll take longer right?

A wifi connection does extra things that a plain ethernet link doesn't - that's the delay, there's nothing to be done, laws of physics and all that.

The best you can do is be close to a very good wifi base-station that's attached to the primary network with the best latency.

Now I want a quarter-cheese...

Chopper3
  • 101,299
  • 9
  • 108
  • 239
  • 1
    you are correct that wifi adds delay, but not 200ms worth of delay. It can be seen easily on the speedtest page done via WIFI: the ping time to the speedtest site is 8 ms. There must be something else going on... – Martin Jun 14 '22 at 12:18
  • @Martin Yeah, I think so – user15964 Jun 14 '22 at 12:33
  • 3
    @user15964 WiFi is sensible to interference. Do you have 10 neighbour each sharing channel ? or channel overlapping ? do you use 2.4Ghz or 5ghz ? do you have a neighbour that directed their antenna toward your setup ? Did you have updated your wifi card driver ? ... But in general the wifi will never have the same speed as cabled because you dont control the signal path and inteference, – yagmoth555 Jun 14 '22 at 12:50
2

It may be related to the Way your Operating System (Windows 10) trust or not your network leading to possible VPN features.I'm talking about network profiles in Windows (private, public).

1. First suggestion:

Open your VPN settings (System > Network and Internet > VPN) and disable the advanced settings:

  • Allow VPN over metered networks

  • Allow VPN while roaming

Try to traceroute again in both situation to see any changes.

2. Second Suggestion:

Try to change the network profile (in both situation), and check for impacts on your traceroute.

Below is a CMD command to do it quickly (on all interfaces). Do it as ADMINISTRATOR rights.

Set all connections to 'private' profile :

powershell -c "Get-NetConnectionProfile |Set-NetConnectionProfile -NetworkCategory private"

Set all connections to 'public' profile :

powershell -c "Get-NetConnectionProfile |Set-NetConnectionProfile -NetworkCategory public"

Try to traceroute again in both situation to see any changes.

3. Third Suggestion:

It appears that your ISP provider router (in the other side of your ethernet wire) seems to redirect differently your network traffic depending on the connected device.

Try to configure your Wifi Router WAN interface (the ethernet wired interface) by changing it's MAC address to something more 'Workstation related', for example something very similar to your Windows 10 workstation ethernet MAC interface.

Then try to traceroute again to see if it has effect on the latency and routes.

1

I partly solved my problem.

Since my cable network acquires IP dynamically. I found I can just let wifi router run in AP mode so that it just expand the cable network instead of build a new one. Now the trace route is short and fast.

user15964
  • 121
  • 6
0

In general, Wi-Fi connections will always be slower than ethernet because wireless signals will always weaken the further you get from the router. By contrast, wired connections do not degrade over distance and deliver much more consistent bandwidth and stable speeds

The maximum speeds of many Wi-Fi protocols are slower than speeds offered by common ethernet connections. Even if higher, Wi-Fi speeds are significantly more affected by interference, distance, and signal strength, resulting in slower transfer speeds. If possible, wired connections should be used where speed is critical.

Your WiFi equipment is old and needs replacement to obtain higher speeds

Protocol Maximum Bitrate 802.11b 11 Mbps 802.11a 54 Mbps 802.11g 54 Mbps 802.11n 600 Mbps

  • Thank you for answer. But I do not think it is due to age of my wifi. My wifi support latest wifi-6, and I just tested on RT-AX86U which you probably know. – user15964 Jun 14 '22 at 14:07
  • Switch Off radio support for b,g and if possible, n. Update Wifi drivers on machine and change channel used by wifi device – Stacker-9951 Jun 22 '22 at 14:10