LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows netstat function?

Solved!
Go to solution

Is there a LabWindows function that does the equivalent of the Windows "netstat -s" command? Specifically I'm looking to read the count of UDP receive errors. 

0 Kudos
Message 1 of 7
(580 Views)

I'm not aware of such a function, but a quick and dirty solution could be to limit the command in order to reduce the information received, pipe the output to a file and extract the interesting values from it:

netstat -s -p udp >> c:\netstatLog.txt

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 7
(548 Views)

(reply deleted)

0 Kudos
Message 3 of 7
(530 Views)

I found some useful information in a user group post you made years ago:

 

https://forums.ni.com/t5/LabWindows-CVI-User-Group/How-to-get-informations-on-the-system-through-WMI...

 

After much trial and error, I figured out how to do something similar to read datagram statistics from the Win32_PerfRawData_Tcpip_UDPv4 class. I got it to work in a standalone application, but my goal was to integrate it into a LabWindows test tool that I use to monitor a radar system. When I try to do that, it causes a conflict with an ActiveX control used by our frame grabber card.

 

I was hoping to find a way to do this programmatically instead of having to make my application repeatedly launch netstat and parse the output from a text file, but it appears this may not be possible.

0 Kudos
Message 4 of 7
(513 Views)

You could try changing the concurrent mode in InitWMIQuery () this way:

hres =  CoInitializeEx (0, COINIT_APARTMENTTHREADED); 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 7
(495 Views)
Solution
Accepted by topic author richferrara1

WMI may seem interesting but is really like trying to use a cannon to kill a bug. It's basically a SQL style query interface on top of a huge collection of platform tools. Neat idea to try to combine everything under one "API" but the result is a monster of a beast. And it relies for many things on ActiveX plugins that then call into lower level platform APIs or communicating directly with semi public service interfaces.

 

In terms of netstat like functionality, the lower platform interface that all other tools ultimately will rely on after more or less convoluted roundabouts, would be the IP Helper API: https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/

It's not an easy interface to program with, but much closer to the hardware and still mostly compatible across a large range of Windows versions is not really possible. It avoids threading configuration issues of ActiveX, SQL query specific difficulties and initializing several rather huge framework subsystems at the cost of the programmer having to deal with somewhat unusual memory management schemes.

 

 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 7
(474 Views)

Thank you, I don't know why this didn't turn up in the dozens of Google searches I did but the GetUdpStatistics function in the IP helper library was exactly what I was looking for.

0 Kudos
Message 7 of 7
(445 Views)