14 ms·
Show HN: An ultra-light-weight tool to quickly test your ping
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 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!
- silisili 4y agoReally lightweight, nicely done. For even more sites/pops, https://gcping.com 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.
- isatty 4y agoI’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 4y agoThe 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 4y agoYou 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 4y agoSuper great points, I'm going to experiment with these ideas a bit and see how it goes.
- vdfs 4y agoNot an expert but this doesn't seem like normal ping, it's rather how much HTTP request take including handshakes and content download
- netsharc 4y agoI 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 4y agoNot 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 4y agoThis 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.
- Matthias247 4y agoThe 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/Navigation_and_resource_timings https://developer.mozilla.org/en-US/docs/Web/Performance/Nav...
- KMnO4 4y agoWon’t the browser first do an OPTION before the test (GET) starts? The lookups should be cached.
- Matthias247 4y agoyou can check it in the network tab. It won't.
- a1445c8b 4y agoGreat 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 4y agoThese 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/ 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.
- Wxc2jjJmST9XWWL 4y agoSorry 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
- andrepd 4y agoI for one welcome the era of PaaS (ping as a service).
- goodpoint 4y ago...for only $9 a month.
- ipsum2 4y agoHow 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 4y agoespecially 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 4y agoWhy 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"
- amelius 4y agoNice. Now all you need is a catchy URL so people can remember it.
- ultrahax 4y agoI miss Netalyzer ( http://netalyzr.icsi.berkeley.edu/ http://netalyzr.icsi.berkeley.edu/ )
- therealdrag0 4y agoI like this one which I think was a Show HN a while ago https://github.com/apenwarr/blip https://github.com/apenwarr/blip
- sammy2255 4y agoI use https://www.cloudping.info/ https://www.cloudping.info/ Although it’s sad to see they put political messages in it now
- ipython 4y agoI 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 4y agoThey could be using anycast, but the pings for Digitalocean seemed correct to me
- tfsh 4y agoI think it's sad we live in a world where an unobtrusive acknowledgment of modern day slavery is adversely received.
- sammy2255 4y agoI’m against slavery. I’m also against putting political messages into software
- mcluck 4y agoWhy?
- RadiozRadioz 4y agoSame 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.
- MikeYasnev007 4y ago
- KennyBlanken 4y agoCan 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 4y agoFair 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.
- patricklorio 4y agohttp://ping.playit.gg/ 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 4y agoOh snap, that is cool! Does the server use raw sockets to pull that off? Or are regular ole TCP sockets capable of this?
- patricklorio 4y agoIt’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.
- PNWChris 4y agoOP here! Great discussion, it's made me realize I should also share my favorite speed test: https://www.waveform.com/tools/bufferbloat 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.
- 2b3a51 4y agoPerhaps pop a noscript tag in the page with a warning ('this page uses a javascript function')?
- dave_taht 4y agoflent.org has some heavy duty, wonderful graphic tests.
- heywoodlh 4y agoThis 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 https://github.com/heywoodlh/bash-uptime [2] https://hub.docker.com/r/heywoodlh/nfcapd https://hub.docker.com/r/heywoodlh/nfcapd
- IndigoIncognito 4y agoLove it