I have seen alot of requests on how to implement network statistics
in .NET applications lately, however, I have not been able to find any .NET classes that do this.
I decided to write a simple VB.NET example on how to implement this with
the help of the IP Helper API's. I am fairly new to .NET so the
code approach might not be 100% 'politically correct' at all times, but I have
tried to keep this as much .NET as I could. If you see something awful, please disregard it.
Using the Code
NetStat class is the parent class because the class has several sub-classes:
ICMP. These classes contain properties which hold network
statistics. You have to update these properties with the Class.Update method.
This method takes an optional parameter in the
TCP classes. If set to
this will update information which is not likely to change. The default is
Also, if anything went wrong in the Update method, the return value is 0, so it's
non-zero on success (It returns the size of structure). You get the error message by retrieving the
I have included a sample project with it, so you will get the picture pretty fast.
It can look something like this;
Dim clsUDP As New NetStat.IP
If clsUDP.Update() <> 0 Then
MsgBox("Datagrams received: " & clsUDP.InDatagrams.ToString)
Msgbox "An error occured; " & clsUDP.LastError
If you find a bug or if you think there is something wrong with the code
please mail me about it! Finally; Tips, comments and/or suggestions would be deeply appreciated! Thank you.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.