I am new to networking and I wanted this kind of environment. is there any way to measure network latency using ping between two hosts, given the condition you are not logged into either of the hosts? I.e you are in a 3rd host and you wanna measure latency between 1 and 2. Will that be possible?

To be more specific, I have a list of servers in a file called as "hosts". I want to measure latency between every one of those like a star connectivity. Will it be possible to do? I have come up with a rough algorithm like this:

    for each in hosts:
            ssh into each
            for all in hosts:
                    if each != all:
                         ping all.

But once you ssh into a different host, how to make the program running is my question.

Thank you in advance

  • 1
    Ping is a pretty poor measure of latency. ICMP doesn't reflect how UDP or TCP will perform. – Ron Maupin Jun 29 '16 at 1:58
  • @Ron Maupin Could you kindly suggest any other better way? Will "Trace Route" do? – sush Jun 29 '16 at 15:05
  • There are real network management tools, some may be part of the network infrastructure devices, e.g. IP SLA,, but product or resource recommendations are off-topic here. – Ron Maupin Jun 29 '16 at 15:10
  • @Ron Maupin Thank you for the information. I am not allowed to use any kind of tools as such. It has to be coded from scratch. – sush Jun 29 '16 at 17:33

It's as simple as:

ssh host ping host2

but you'll probably want a loop inside a loop to do it. However, this isn't a very good idea (it's fragile, kinda pointless, and smells like a symptom of bigger problems).

  • Thank you. Could you kindly let me know what problems I might be anticipating. Also could you let me know how this problem could be solved in a better manner? – sush Jun 29 '16 at 14:38
  • well, if youre pinging over the internet there's little you can do about the differences if/as/when they occur. There's also things like smokeping that'll probably do a better job rather than write your own, and by problems i mean 'making a networking decision based on an icmp ping'. So its probably not terribly useful information. I might be guessing wrongly, but to me it sounds like the a thing someone would want put on a TV dashboard, but never actually used for any business purpose. The short story is what youre trying to do likely isn't a good idea, and this isnt the best way to do it – Sirex Jun 29 '16 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.