Easilly:
While loading page, add js request to serverside, which will give a client public ip.
On server side, in your backend script lang exec cli command ping client.ip.add.ress -c 1
then parse it relatively on your OS and your backend scripting lang, and return value of msec result to your web page.
On webpage, based on your js code, print readable result to user on webpage.
It can be repeated time after time, cause network can be changed, time to time, and it's will be pritty nice to constantly refresh value. And don't forget to catch any exceptions, like ping forbid or firewall or ping packet loss.
i hope you also doing well. Cheers!