Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

ICMP Ping & Trace

Started by Biterider, January 06, 2023, 02:58:06 AM

Previous topic - Next topic


Recently I needed to check if a server is down, and the easiest way to do this is to use the ping command.
If you need to do this from your application, you either have to deal with raw sockets, all their complexities and admin privileges, or you can use the well-known IcmpSendEcho API.

With the latter, the implementation is fairly straightforward, and as a bonus, the trace command can be coded just as easily.
I had to translate the appropriate header file and the rest was more or less standard coding.

In the attachments I've included as reference a 32-bit test application, the ping and trace code, and the and files, that are required to use the IcmpSendEcho API.  :biggrin:



'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'


Hi Biterider,

:thumbsup: Thanks for the example! Is it possible to extend the example to a library?

liboping-master Protocol independent ANSI-C ping library and command line utility

  liboping was inspired by ping, libping and fping: It differs from these
  existing solutions in that it can "ping" multiple hosts in parallel using
  IPv4 or IPv6 transparently. Other design principles were an object oriented
  interface, simplicity and extensibility.


  • Support for multiple hosts.

  • Support for IPv4 and IPv6.

  • Object oriented interface.


Hi LiaoMi
Yes, it is quite possible to create a static library, but I don't think it is worth it.  :rolleyes:
Basically, you only need to call 1 Win32 API (IcmpSendEcho/Icmp6SendEcho2) to execute a single ICMP ping.
To save time you can execute multiple pings asynchronously. This only requires an event object and a call to IcmpSendEcho2/Icmp6SendEcho2 for each host.