Live data from Hacker News

Show HN: An ultra-light-weight tool to quickly test your ping

ping.projects.chrisjeakle.com

1–10 of 64 posts

Show HN: An ultra-light-weight tool to quickly test your ping

#1
Howdy HN!

I find myself testing my ping from time to time, especially when my internet seems wonky while WFH. It feels like there should be an easier way test my ping than puling up a terminal or a complex web app - especially when I'm on my phone or any other device that doesn't have a terminal.

I figured I should be the change I wish to see in the world and created this super light ping test.

I also created a latency monitoring solution (https://github.com/cjjeakle/network-monitor), feel free to clone and try it out! I know there are a lot more mature monitoring solutions out there, but I never did figure out how to set them up. This one is super simple: clone it to some device that's always on, compile it, set up some systemd stuff, and it's ready to rock on port 8180!

Show HN: An ultra-light-weight tool to quickly test your ping
ping.projects.chrisjeakle.com

Re: Show HN: An ultra-light-weight tool to quickly test your ping

#5
post #3

I’m on my phone and I can’t debug/look into it but the jitter is very high. Over 5 tries I’ve received widely varying ping times to SF, two of which were 1s while NYC was 140 ms ish. Just weird because I’m on a reliable connection in SF (sonic).

The code my clarify that up, it simply calculate how much time an http request take to complete:

  function ping_test() {
     time_request("http://ping.projects.chrisjeakle.com/ping/data.txt", "result-east");
     time_request("http://ping.projects-west.chrisjeakle.com/ping/data.txt", "result-west");
  }

  function time_request(url, output_id) {
      document.getElementById(output_id).innerText = "...";
      const start_time = new Date().getTime();
      fetch(url, {
          mode: "no-cors",
          cache: "no-cache",
        }).then(async (result) => {
          const elapsed_time = new Date().getTime() - start_time;
          document.getElementById(output_id).innerText = elapsed_time;
      });
  }

Re: Show HN: An ultra-light-weight tool to quickly test your ping

#6
post #4

Not an expert but this doesn't seem like normal ping, it's rather how much HTTP request take including handshakes and content download

I wonder if it could be done better using WebSockets: setup the connection, start the stopwatch, send a byte, wait to receive a byte, stop the stopwatch, and close the connection.

Re: Show HN: An ultra-light-weight tool to quickly test your ping

#7
post #5
post #3

I’m on my phone and I can’t debug/look into it but the jitter is very high. Over 5 tries I’ve received widely varying ping times to SF, two of which were 1s while NYC was 140 ms ish. Just weird because I’m on a reliable connection in SF (sonic).

The code my clarify that up, it simply calculate how much time an http request take to complete: function ping_test() { time_request("http://ping.projects.chrisjeakle.com/ping/data.txt", "result-east"); time_request("http://ping.projects-west.chrisjeakle.com/ping/data.txt", "result-west"); } function time_request(url, output_id) { document.getElementById(output_id).innerText = "..."; const start_time = new Date().get…

You should consider switching to window.performance.now() as that is a monotonically increasing clock, instead of a wall clock that might randomly be adjusted with time sync services.

Also, maybe you should run the tests in sequence instead of at the same time. I wonder if running two concurrent fetches might disadvantage the second fetch?

Re: Show HN: An ultra-light-weight tool to quickly test your ping

#8
The times will be super different between initial load and retries, since the first request requires a potential DNS lookup, establishing a TCP connection, and potential TLS handshake, and only then the request can be performed. Follow-up requests don't require an additional connection.

If you want timings only for TCP connection establishment, or only for the request, you can use the browsers navigation timing APIs to get those: https://developer.mozilla.org/en-US/docs/Web/Performance/Nav...

Re: Show HN: An ultra-light-weight tool to quickly test your ping

#9
Great start!

One way you could improve this is to not stop at just reporting a single data point but report the P50, P75, and P90 of a reasonable set of data points.

Also, it's probably better to call this HTTP latency rather than ping since the latter is on a much lower layer in the OSI model.

Re: Show HN: An ultra-light-weight tool to quickly test your ping

#10
post #4

Not an expert but this doesn't seem like normal ping, it's rather how much HTTP request take including handshakes and content download

Not entirely.

Modern browsers / webservers will keep TCP connections alive for at least a few minutes. I ran a tcpdump and confirmed there's only one network round trip involved in the critical path (after the first request, anyhow), with a transfer of a few hundred bytes in each direction (HTTP overhead, but nowhere near big enough to incur processing delays on the same scale as propagation delay).

(The actual packets sent: HTTP GET from my end, HTTP response from the server, ACK from my end.)

The latency is still 20-40ms higher than ping times, although it's not clear to me whether that's due to disk seek latency, server load, or something else.

Post reply on HN