0

I am using Delphi 11 FMX to write for Linux and Windows.

I have an auto-ping program working well on both platforms, using TIdIcmpClient.

But now, I want to write a program that will ping up to four different IP addresses, displaying a flag when an address goes down. I could, of course, ping one IP and then change the IP and ping another. But I have seen that the first ping is always longer, although I have usually pinged in seconds of interval, once every 5 seconds, for example. The first ping is always much higher than the rest. So, in my program, I ignore the first ping.

I am afraid that if I use one TIdIcmpClient, changing IPs before every ping, it will always be a first ping, and so will not represent the real round trip time. Or does this happen just the first time the TIdicmpClient pings?

Alternately, perhaps I should use multiple TIdIcmpClient components? But I don't know if it is okay to use multiple TIdIcmpClients. This program would ping each address perhaps once every 10 seconds at most, more likely once a minute.

I am looking for advice that will save me time when I write this program. I searched for this on StackOverflow, and elsewhere. I found some useful things here, but nothing this specific.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Crash
  • 1
  • 2
  • I would suggest to instead focus your efforts on diagnosing why the "first" ping is always longer than the others, so you don't have to keep ignoring it in the first place. As for whether to use a single or multiple `TIdIcmpClient` objects, I don't think it really matters one way or the other, unless you are pinging multiple IPs in parallel, then you must use multiple objects. – Remy Lebeau Jan 18 '23 at 19:23
  • You suggest I find out why the first ping is always long. I thought I had learned that from the YouTube tutorial I was following when I learned to ping. SO I just watched it again: https://www.youtube.com/watch?v=UOR0vFd7kds At first when he pings using a button it doesn't seem to happen. But when he adds a chart and timer you can see each time he starts pinging the first ping is always much longer. He even says "you might want to ignore the first couple of pings". So it isn't just me. – Crash Jan 19 '23 at 17:34
  • When I was following the video I stopped it, did it, then thought of adding a timer and chart, and did get those working, before I continued and found he added a chart and timer too. Not sure how I would approach diagnosing why it happens. I just found a tutorial on YouTube about pinging four addresses simultaneously. But it had no sound, was Microsoft visual studio and C#, and was on a french computer. – Crash Jan 19 '23 at 17:36
  • "*Not sure how I would approach diagnosing why it happens*" - by using the debugger to see what is really happening under the covers. Also, by using a network sniffer/analyzer, like Wireshark. Is the delay because the pings really are long on the network, or because they are slow to be processed by `TIdIcmpClient`? It makes a big difference one way or the other. – Remy Lebeau Jan 19 '23 at 17:55

0 Answers0