annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

Ping Ping Ping - Native Win2k/LV7 code

Hi all Thanks to the contributor of this utility. I had some problems with it though. My problem is that each call to 'Raw Socket Ping' uses 3 Windows Handles (viewable with Task manager, add the Handles column) and it never releases the handles. I don't know how many handles Win has available, but it is limited, and when you run out of handles you cannot do anything else on the PC until you close the LV app. I tracked the problem down to the DLL calls to WSASocket() and SendTo(). These functions grabs 2 and 1 handles respectively and WSACleanup() never releases them. I only call the 'Raw Socket Ping' vi. Is there some cleanup code that should be called? Any help will be welcome.
0 Kudos
Messaggio 11 di 32
10.122Visualizzazioni
From this website it seems as though you need some sort of delete function. Is it possible to do that with a DLL call? This one also talks about a DestroyHandle function. Maybe that is the way to go?
Regards,

Hillary E
National Instruments
0 Kudos
Messaggio 12 di 32
10.087Visualizzazioni
Thanks Hillary,

There is a closesocket() function in the ws2_32 dll that I now use to close the handles. It seems to be working for the moment
0 Kudos
Messaggio 13 di 32
10.086Visualizzazioni

wimpie,

      Thanks for the tip re: adding/monitoring "handles" column of task-manager! Smiley Felice

Cheers.

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Messaggio 14 di 32
10.061Visualizzazioni


@m3nth wrote:
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.


Well, thanks for the library!

I cleaned it up a bit, fixed the problem about to small (not to big buffer as a remark would indicate) buffer in WSA Startup and added a Close Socket function to avoid handle leakage. I also changed the select() call to be reentrant to allow multithreaded parallel execution of pings without blocking.

There is one problem with this in respect to error reporting and in case of parallel execution of this ustility in general that the WSA error is maintained on a thread specific global variable. So for this select call the reported error in case of a failure never will be the real error since the select call happens in one of the multi threaded execution systems while the error retrieval will occur in the UI thread. Also if you run multiple ping calls in parallel, the error may get overwritten by the execution of one call before another VI had a chance to retrieve it's associated error.

Rolf Kalbermatter




Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Messaggio 15 di 32
9.926Visualizzazioni
I was wondering if you can modify this code so that it acts as a packet sniffer that can timestamp ethernet packets as they arrive?  I tried mucking around with it to no avail...
0 Kudos
Messaggio 16 di 32
9.536Visualizzazioni

No the winsock API is not able to work in promiscious mode AFAIK. For that you need a low level packet driver such as winpcap and there have been people working on some LabVIEW VIs to access that driver. However from what I gathered to be able to do a real fully fledged packet sniffer there are still some substantial Vis missing and the application on top of that to make it user friendly would be a major project in itself. Wouldn't see why to do that instead of using Wireshark or some other commercial network analyzer software.

 

Rolf Kalbermatter

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Messaggio 17 di 32
9.526Visualizzazioni

Might want to look at a hardware solution for sniffing. Look at the Aggregator taps here. http://www.vssmonitoring.com/products/a_taps.asp 

 

I've also seen some software from Fluke Networks that will monitor a tap. I think it was called Optiview. http://www.flukenetworks.com/fnet/en-us/products/OptiView+Protocol+Expert/Overview.htm

0 Kudos
Messaggio 18 di 32
9.511Visualizzazioni

I thought I read in the MSDN.net that one can place Winsock in promiscuous mode per MSDN stuff.   It looks like the WSAIoctl function can control the promiscuous mode.

 

http://msdn.microsoft.com/en-us/library/ms741621(VS.85).aspx

 

There is a section in the above link that describes how to set Winsock to promiscuous mode.

SIO_RCVALL (opcode setting: I, T==3)

Enables a socket to receive all IPv4 or IPv6 packets on the network.

 

 


 

0 Kudos
Messaggio 19 di 32
9.490Visualizzazioni

Well, nice library.
 
I tried it on Vista32/LV82 and it does not work.
*SOCKET create.vi* make always *INVALID_SOCKET* Error.

If I know how to fix, I will report here.

 

0 Kudos
Messaggio 20 di 32
9.342Visualizzazioni