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

ping.projects.chrisjeakle.com

96 points by PNWChris a year ago

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!

Wxc2jjJmST9XWWL a year ago

Sorry for being unappreciative but... is this... satire? I honestly don't know...

'easier way to test my ping than pulling up a terminal', ... so a non https website that needs javascript is better than terminal-shortcut + <terminal>$ ping 8.8.8.8</terminal> (or whatever you want to ping, you also could set up an alias/function in your .bashrc to do something more complex)...

can I hit that point home: "easier way than pulling up my terminal", answer: a non-https javascript needing website!!!

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

"super simple"... sounds... super simple... installing rust nightly as we speak to build it /s

this world of ours

  • PNWChris a year ago

    Fair enough. I think technical users probably don't need this site, but I think there is value to be had (even for those technical users!).

    For a bit of context:

    I found myself using this site via my xbox's web browser to make sure my wifi latency is acceptable where I put the xbox.

    Also, my spouse and I just moved to a new place, so I used this site on my phone to get a quick idea of the latency on wifi in my spouse's office.

    There's tons of web-based tools to test your bandwidth, but I feel there just isn't a similar ecosystem of quick, web-based "ping" (well, latency, since I can't send ICMP packets from a web browser) tools.

    -

    RE: HTTP only, good point. I've set up certbot and the page supports https now. I am not certain how HTTPS will impact the latency measurements, it appears the results are typically a bit higher and occasionally much higher when using HTTPS.

    -

    I don't get the disappointment with the use of JS. It's just a bit of inline JS, easy to manually audit if concerned. JS is quite safe IMO and is a very powerful tool, it makes a rich universe of interactive applications possible in the humble web browser. I basically got into CS because of the fun I had creating things for and sharing things on the web.

    • alrlroipsp a year ago

      > so I used this site on my phone to get a quick idea of the latency on wifi in my spouse's office.

      Sure you did. But there's a whole category of phone apps called Wifi Heat maps, that would actually be "super simple" for a non-techie to use.

      People are commenting on your use of javascript, where you are arguing that you built a super simple solution. As many already pointed out, the ping command is already there and is more "super simple" to use than to self host a website to get a skewed HTTP "ping" from some cloud service...

  • ipsum2 a year ago

    How was it possible to read "easier way to test my ping than pulling up a terminal" but not finish the sentence to "especially when I'm on my phone or any other device that doesn't have a terminal"?

    • userbinator a year ago

      especially when I'm on my phone or any other device that doesn't have a terminal

      Mine does, and in fact I have used the ping command from it before. I highly recommend having a terminal app.

      • smabie a year ago

        Why do you highly recommend it? Don't think I've ever thought while using a phone "damn I wish I had a Linux terminal handy"

        • userbinator a year ago

          I suppose if you don't think of your phone as the general-purpose computer that it really is, then it won't seem obvious. But otherwise, I also recall using dig, netcat, traceroute, and a few other network tools a few times. Having a shell, even a root one, is one of those things that you don't need often, but when you do, you really do.

          • the_only_law a year ago

            I mean I know what my phone is. I just do not want to use that interface for those sort of tasks. Tiny little screen, virtual keyboard that tries to hard to be clever, etc.

            Even browsing the web to read wikis and documents and stuff is a complete pain half the time.

            • dinom a year ago

              How I miss my galaxy S3!

              I'd hook it up to a proper display using an MHL cable then connect a Bluetooth keyboard. It was a sweet setup and the assorted tools (plus root shell) actually came in very handy. It could fill in for a laptop quite nicely.

              These days it seems there's no legitimate alternative to MHL... can any phones directly connect to a display anymore via wire? Or is the only option screencasting to a smart TV?

              FWIW, I generally like my appliances on the dumb (or open) side.

              • MayeulC a year ago

                A lot of phones can be connected to an external display via USB-C. Better supported than MHL (how many incompatible standards was MHL? 4?).

                Samsung has "Dex", their android desktop interface.

                Linux phones can generally offer a full DE, either the pinephone or Librem, or compatible phones that have a video out where you can install something likke postmarketos.

                Most phones also support miracast, and you can plug in a mouse/keyboard. I think the Charging in + keyboard + mouse + video out is clearer with USB-C.

                Sent from my Galaxy S4 ;)

                • e-clinton a year ago

                  Much easier to just carry my MacBook everywhere as I already do.

            • forgotpwd16 a year ago

              >I just do not want to use that interface for those sort of tasks.

              That is your preference. For others the advantage of utilizing a familiar interface outweighs the disadvantages (that maybe even aren't for some) mentioned.

            • userbinator a year ago

              Neither do I. Yet sometimes that's the only thing you have on hand.

        • yjftsjthsd-h a year ago

          > Don't think I've ever thought while using a phone "damn I wish I had a Linux terminal handy"

          Then maybe it's not for you, but some of us absolutely have had that thought and find it incredibly useful.

          • smabie a year ago

            Again, why is it "incredibly" useful?

            • MayeulC a year ago

              You need to diagnose something on your laptop that has stopped accepting input or with a blank screen. plug in your Android phone, enable USB tethering, ssh in.

              You are on holidays, your need to help someone (or yourself) with some server issues. Use your teminal to ping them, ssh, etc. Later, no Internet at your rental house. No computers. Fire up the terminal,diagnose the issue. nmap the network if you need to find the IP of something (also, to check for cameras? IDK).

              It's just a huge toolbox, batteries included. You might not need it. It can certainly come handy, especially if you have no Internet to download the corresponding app.

              I don't use it often, but when I do, it's much better to have it than not having it.

            • emj a year ago

              FWIW This ping/latency tool is a great tool and impressively terse, I've had to implement it myself several times the last 20 years for reasons. So I am glad someone actually shipped a tool for it.

              To answer your question: I think your point of view need to change. The need we want to full fill is to do computer stuff, we have a pretty neat computer in our hand it is clear we want to use it as such.

    • alrlroipsp a year ago

      I mean most of us techies know better ways.

      On your phone you run for example Fing

      Fing iOS: https://apps.apple.com/us/app/fing-network-scanner/id4309211...

      Fing Android: https://play.google.com/store/apps/details?id=com.overlook.a...

      With Fing App’s free tools and utilities help you:

      • Scan networks with Fing’s Wi-Fi & LAN network scanner and discover all devices connected to any network

      • Get the most accurate device recognition of IP address, MAC address, device name, model, vendor and manufacturer

      • Run WiFi and Cellular internet speed tests, download speed and upload speed analysis and latency

      • Browse internet outages in your area, ISP ratings, reviews and speed statistics

      • Advanced device analysis of NetBIOS, UPnP, SNMP and Bonjour names, properties and device types

      • Includes port scanning, device ping, traceroute and DNS lookup

      • Receive network security and device alerts to your phone and email

    • dicknuckle a year ago

      Can't say I've ever felt the need to test ping from my phone other than finding out if my wifi AP was dead while I was in the attic troubleshooting. There's an app for that.

    • yjftsjthsd-h a year ago

      My phone does have a terminal, and I run ping in termux regularly.

  • thehappypm a year ago

    This isn’t Shark Tank. OP built something to share, not looking for seed funding or a Nobel. Relax!

  • dicknuckle a year ago

    It's even easier to have a ping going in the corner of my laptop screen. Since the Win7 days I've used SimplePing, on my work Mac the app store wanted 99c for this privilege but there's a free one that does the same thing.

  • hatware a year ago

    Definitely has a "but why?" vibe to it. OP probably learned a lot getting this up and that's usually what motivates me to learn.

  • andrepd a year ago

    I for one welcome the era of PaaS (ping as a service).

    • goodpoint a year ago

      ...for only $9 a month.

a1445c8b a year ago

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.

  • PNWChris a year ago

    These are great points, I appreciate it!

    Labelling this a "ping" was a poor choice on my part. I meant ping in the RTT/latency sense, rather than an ICMP sense. Calling it "HTTP latency" is a huge improvement that clearly (and concisely) gets the idea across, I made a quick edit to do just that.

    RE: recording a range of samples and reporting percentiles: My hope is to keep the code super simple and the delay to visible info in the UI very low. Elsewhere in the thread folks mentioned the excellent http://gcping.com/. That site has a ton of destinations to test latency to and reports the median of a number of samples - that is a really cool feature set! I don't think I'll be able to do anything close to that in tens of lines of inline JS, unfortunately.

    Still, the measurements start super noisy and I'd like to ensure my site gives useful data even at the start. I did a bit of a hack to hopefully force the RTT to converge to something useful. I now fire off 3 time-delayed measurements after the page loads. By the time the third finishes, the numbers appear to be pretty stable.

silisili a year ago

Really lightweight, nicely done.

For even more sites/pops, https://gcping.com exists which I believe pings each GCP region worldwide. It feels a bit heavier, as it takes at least a few seconds before I see (relevant to me in the US) results.

heywoodlh a year ago

This is super cool! I like the ability to review previous results. Not sure why people are getting so hung up on how ping in the terminal is so much simpler.

Not sure if this is desired, but if at some point alerting was built into this, that would be awesome.

---

On a related note, I currently use the following tools to monitor my network:

- bash-uptime[1] -- BASH script I wrote for simple (for me) icmp/http monitoring.

- iPerf3 server so I can test my bandwidth speeds over the LAN or Wireguard

- Nfcapd/nfdump to ingest netflow from my firewall and router and give me the ability to search that netflow with nfdump (I have a multi-arch Docker image for Nfcapd that I maintain[2])

- Syslog-ng to ingest logs and write them to my filesystem with some scripts I use to search the logs quickly via grep

- Gotify for all my network-related notifications

[1] https://github.com/heywoodlh/bash-uptime

[2] https://hub.docker.com/r/heywoodlh/nfcapd

sammy2255 a year ago

I use https://www.cloudping.info/

Although it’s sad to see they put political messages in it now

  • tfsh a year ago

    I think it's sad we live in a world where an unobtrusive acknowledgment of modern day slavery is adversely received.

    • sammy2255 a year ago

      I’m against slavery. I’m also against putting political messages into software

      • mcluck a year ago

        Why?

        • RadiozRadioz a year ago

          Same reason most people don't like banner ads. It's extra fluff the user didn't ask for, unrelated to the stuff they actually want to see. It's not the case here, but oftentimes the political messages can be large and distracting, think Notepad++. That's reason enough to dislike them, without getting into any of the "purity" arguments.

      • nextaccountic a year ago

        You're against slavery, but not against doing the slightest gesture against it, even if it barely inconveniences you?

  • ipython a year ago

    I would take those numbers with a grain of salt. That site claims I have a 3ms ping to a digital ocean droplet in Singapore. Either I have proven faster-than-light information transfer or that measurement is off by several orders of magnitude.

    • Jamie9912 a year ago

      They could be using anycast, but the pings for Digitalocean seemed correct to me

patricklorio a year ago

http://ping.playit.gg/ embeds the request epoch in the TCP sequence number to give you your ping.

  Client SYN => 
             <= Server SYN+ACK \w epoch in sequence
  Client ACK =>
             <= HTTP payload calculating ping with NOW - ACK number
  • PNWChris a year ago

    Oh snap, that is cool! Does the server use raw sockets to pull that off? Or are regular ole TCP sockets capable of this?

    • patricklorio a year ago

      It’s custom software for tunneling (primarily game servers). All the packets are handled directly using AF-XDP. It’s also on an anycast network and this endpoint is used to debug routing issues.

Matthias247 a year ago

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

  • KMnO4 a year ago

    Won’t the browser first do an OPTION before the test (GET) starts? The lookups should be cached.

    • Matthias247 a year ago

      you can check it in the network tab. It won't.

PNWChris a year ago

OP here! Great discussion, it's made me realize I should also share my favorite speed test: https://www.waveform.com/tools/bufferbloat

It both tests bandwdith and gives some cool latency measurements (both idle and under load). It's super helpful at diagnosing bufferbloat if there is any on your network connection.

I don't run it much since I don't want to tear through my ISP's data cap, but is an excellent tool.

vdfs a year ago

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

  • netsharc a year ago

    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.

  • vitus a year ago

    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.

    • PNWChris a year ago

      This is super helpful context, thank you! I was wondering why the RTTs appeared to converge only after a couple retries, and why the first measurement was so wildly different when pulling up the page after some time away.

isatty a year ago

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).

  • vdfs a year ago

    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;
          });
      }
    • 0x0 a year ago

      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?

      • PNWChris a year ago

        Super great points, I'm going to experiment with these ideas a bit and see how it goes.

amelius a year ago

Nice. Now all you need is a catchy URL so people can remember it.

2b3a51 a year ago

Perhaps pop a noscript tag in the page with a warning ('this page uses a javascript function')?

KennyBlanken a year ago

Can HN please reject any submissions that are not HTTPS urls? The number of sites that get submitted here via plaintext http is shocking.

To anyone who just started typing out something to inform me that "it doesn't matter on _______ site because _______": there are four purposes of encryption, not just "confidentiality."

  • PNWChris a year ago

    Fair point! Just got all the certbot stuff set up. Wasn't too bad, though at first glance it appears there may be a bit more variance in the RTTs.

    Edit:

    I think I found a way to get the best of both worlds!

    I've removed certbot's 301 redirect from HTTP to HTTPS and made it so the protocol used during latency measurements matches the page's state. Now if one wants HTTPS they can use it, but if they want a slightly more stable measurement they can use the http page.

dave_taht a year ago

flent.org has some heavy duty, wonderful graphic tests.