From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ping Ping Ping - Native Win2k/LV7 code

There have been several posts (including one from myself 🙂 requesting code to perform a network ping. Shelling out to the OS simply wouldn't work for me so this code uses raw sockets in Win2k to perform an ICMP ping and get the echo reply back. This code is limited and simple but it could easily be modified--it has worked well for me to monitor the status of network communications. Enjoy.
Message 1 of 32
(19,670 Views)
Hi,
thanks so much for sharing it!!!
I really needed it.
In many network applications I have to check the pc's status, I have used several tricks but not as efficient as yours.
Thanks again!
Alberto
0 Kudos
Message 2 of 32
(19,653 Views)
From the other posts its sounds like the code that you developed wil be very useful for a lot of other customers.

I would suggest going to Example Code Library and submiting your code as a new example. That way more people can find it and benefit from it. In addition you will be able to take credit for your hard work.

Thanks for the posting and the code.

Evan
National Instruments
0 Kudos
Message 3 of 32
(19,652 Views)
Good idea, I'll do that.
0 Kudos
Message 4 of 32
(19,652 Views)
can you post a version for LabVIEW V6.0 or LabVIEW V6.1
    - do a "Save with options"  then select "for previous version"
 
thanks
0 Kudos
Message 5 of 32
(19,289 Views)
Hello,

I took a quick look at the code, and it uses Express VI's in several locations.  Express VIs are a feature that was first introduced in LabVIEW 7.0, and are not compatible with versions earlier than 7.0.  Saving for Previous will not work in this case - the author of the code would need to rewrite the VI's to use only features supported in the earlier versions.

If you want to perform a network ping operation you still have the option of using the System Exec VI to run the system ping function from the command line:


Message Edited by MattP on 03-15-2007 09:35 AM

Cheers,

Matt Pollock
National Instruments
0 Kudos
Message 6 of 32
(19,254 Views)

Hello Fellow Pingers,
      Belated thanks to m3nth for this valuable tool  My multi-threaded app ran into a snag, though; seems one of the WinSock2 calls "blocks" and doesn't allow a ping to be sent while waiting for another.  Long story short, to obtain good time-received resolution would have required "polling".

Fortunately the WS2 API can be configured to send a message to a Window on a socket-receive event, and this old utility allows LabVIEW to convert a Windows message into an occurrance - turning the ping-polling loop into a wait for ping-received-event loop. Smiley Happy

The attached tool - back-saved to LV 8.0 - is dedicated to m3nth who made it possible and who long ago proved he's a LabVIEW wizard!

P.S. Earlier this year Matt pointed-out that the DOS ping command accessible through a SysExec call.  The DOS ping is probably most accurate but unfortunately very limited. Besides (apparently) not able to ping faster than 1Hz, it also blocks (so pings in seperate threads end up running synchronously.)

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 7 of 32
(19,048 Views)
Hi tbd

I tried running your code, but it seems to be missing "Windows Messages for LabVIEW.dll"
Is this your own dll or should it be installed with LabVIEW? (I am running LV8.5)

nrp
Message 8 of 32
(19,032 Views)

Hi nrp,

      Good point!  The DLL is available from NI here (it's bundled in the .zip).

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 9 of 32
(19,010 Views)

follow-up:

The ws2_32.dll asynchronous-pin code posted-above has been working very reliably except that a Windows-registry-hack was required for non-admin Users.  Google "AllowUserRawAccess" for the hack.  (This limitation would apply to the original post as well.)

Since posting, a small mod was made to the implementation of the sendto function - to correctly report errors there, and an additional ws2_32 function was implemented in driver - it converts dot-notation string to U32 IP address - in the format expected by ws2_32.dll.  This is used to "bind" created sockets to a local IP address.

Cheers.

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 10 of 32
(18,809 Views)