473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Status Lan connection - bytes send / recieved

Hi all,

http://www.aswin.be/nictransfer.JPG
How can I get these numbers with VB.NET ?

I thought somewhere in WMI but I can't find them.

Thank you,
Aswin
Jan 10 '06 #1
20 5346
Use PerformanceCounter class. Set CategoryName to "Network Interface" and
select "Bytes Received/sec" etc.

Hope this helps
--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
Hi all,

http://www.aswin.be/nictransfer.JPG
How can I get these numbers with VB.NET ?

I thought somewhere in WMI but I can't find them.

Thank you,
Aswin

Jan 11 '06 #2
But that counter is per second.
How do I know what is send sinds the reboot ?
Or where can I find the elapsed seconds ? So I can multiply it with the
counter bytes/sec.
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:2F**********************************@microsof t.com...
Use PerformanceCounter class. Set CategoryName to "Network Interface" and
select "Bytes Received/sec" etc.

Hope this helps
--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
Hi all,

http://www.aswin.be/nictransfer.JPG
How can I get these numbers with VB.NET ?

I thought somewhere in WMI but I can't find them.

Thank you,
Aswin

Jan 11 '06 #3
If you don't want per sec use RawValue. "Network connection status" and "Task
Manager" display raw value of the "Packets Received Unicast" preformance
counter( well almost - i dont know why "Network connection status" shows
different value for the total packet sent, but the same for received)

Hope this helps

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
But that counter is per second.
How do I know what is send sinds the reboot ?
Or where can I find the elapsed seconds ? So I can multiply it with the
counter bytes/sec.
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:2F**********************************@microsof t.com...
Use PerformanceCounter class. Set CategoryName to "Network Interface" and
select "Bytes Received/sec" etc.

Hope this helps
--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
Hi all,

http://www.aswin.be/nictransfer.JPG
How can I get these numbers with VB.NET ?

I thought somewhere in WMI but I can't find them.

Thank you,
Aswin


Jan 11 '06 #4
You are pointing to this?

VB.NET code:

Try

Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT
BytesReceivedPersec,BytesSentPersec,BytesTotalPers ec FROM
Win32_PerfRawData_Tcpip_NetworkInterface")
Dim totaalverzonden, totaalontvangen, totaal As Int64

For Each queryObj As ManagementObject In searcher.Get()
totaalontvangen = totaalontvangen +
Convert.ToInt64(queryObj("BytesReceivedPersec"))
totaalverzonden = totaalverzonden +
Convert.ToInt64(queryObj("BytesSentPersec"))
totaal += Convert.ToInt64(queryObj("BytesTotalPersec"))
Next

Console.WriteLine("Totaalontvangen: " & totaalontvangen.ToString)
Console.WriteLine("Totaalverzonden: " & totaalverzonden.ToString)
Console.WriteLine("Totaal: " & totaal.ToString)

Catch err As ManagementException
Console.WriteLine("An error occurred while querying for WMI data: " &
err.Message)
End Try

I thought, yess I have finally found it . But the value resets(<-- I tink it
resets) around 5,5 GB.

"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:16**********************************@microsof t.com...
If you don't want per sec use RawValue. "Network connection status" and
"Task
Manager" display raw value of the "Packets Received Unicast" preformance
counter( well almost - i dont know why "Network connection status" shows
different value for the total packet sent, but the same for received)

Hope this helps

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
But that counter is per second.
How do I know what is send sinds the reboot ?
Or where can I find the elapsed seconds ? So I can multiply it with the
counter bytes/sec.
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:2F**********************************@microsof t.com...
> Use PerformanceCounter class. Set CategoryName to "Network Interface"
> and
> select "Bytes Received/sec" etc.
>
> Hope this helps
> --
> Milosz Skalecki
> MCP, MCAD
>
>
> "newbie" wrote:
>
>> Hi all,
>>
>> http://www.aswin.be/nictransfer.JPG
>> How can I get these numbers with VB.NET ?
>>
>> I thought somewhere in WMI but I can't find them.
>>
>> Thank you,
>> Aswin
>>
>>
>>


Jan 12 '06 #5
Yep,

You can use easier approach performanceCounter.NextSample().RawValue

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
You are pointing to this?

VB.NET code:

Try

Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT
BytesReceivedPersec,BytesSentPersec,BytesTotalPers ec FROM
Win32_PerfRawData_Tcpip_NetworkInterface")
Dim totaalverzonden, totaalontvangen, totaal As Int64

For Each queryObj As ManagementObject In searcher.Get()
totaalontvangen = totaalontvangen +
Convert.ToInt64(queryObj("BytesReceivedPersec"))
totaalverzonden = totaalverzonden +
Convert.ToInt64(queryObj("BytesSentPersec"))
totaal += Convert.ToInt64(queryObj("BytesTotalPersec"))
Next

Console.WriteLine("Totaalontvangen: " & totaalontvangen.ToString)
Console.WriteLine("Totaalverzonden: " & totaalverzonden.ToString)
Console.WriteLine("Totaal: " & totaal.ToString)

Catch err As ManagementException
Console.WriteLine("An error occurred while querying for WMI data: " &
err.Message)
End Try

I thought, yess I have finally found it . But the value resets(<-- I tink it
resets) around 5,5 GB.

"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:16**********************************@microsof t.com...
If you don't want per sec use RawValue. "Network connection status" and
"Task
Manager" display raw value of the "Packets Received Unicast" preformance
counter( well almost - i dont know why "Network connection status" shows
different value for the total packet sent, but the same for received)

Hope this helps

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
But that counter is per second.
How do I know what is send sinds the reboot ?
Or where can I find the elapsed seconds ? So I can multiply it with the
counter bytes/sec.
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:2F**********************************@microsof t.com...
> Use PerformanceCounter class. Set CategoryName to "Network Interface"
> and
> select "Bytes Received/sec" etc.
>
> Hope this helps
> --
> Milosz Skalecki
> MCP, MCAD
>
>
> "newbie" wrote:
>
>> Hi all,
>>
>> http://www.aswin.be/nictransfer.JPG
>> How can I get these numbers with VB.NET ?
>>
>> I thought somewhere in WMI but I can't find them.
>>
>> Thank you,
>> Aswin
>>
>>
>>


Jan 12 '06 #6

can you give a little example ?
What about the reset of the value around 5GB ?
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:E1**********************************@microsof t.com...
Yep,

You can use easier approach performanceCounter.NextSample().RawValue

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
You are pointing to this?

VB.NET code:

Try

Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT
BytesReceivedPersec,BytesSentPersec,BytesTotalPers ec FROM
Win32_PerfRawData_Tcpip_NetworkInterface")
Dim totaalverzonden, totaalontvangen, totaal As Int64

For Each queryObj As ManagementObject In searcher.Get()
totaalontvangen = totaalontvangen +
Convert.ToInt64(queryObj("BytesReceivedPersec"))
totaalverzonden = totaalverzonden +
Convert.ToInt64(queryObj("BytesSentPersec"))
totaal += Convert.ToInt64(queryObj("BytesTotalPersec"))
Next

Console.WriteLine("Totaalontvangen: " & totaalontvangen.ToString)
Console.WriteLine("Totaalverzonden: " & totaalverzonden.ToString)
Console.WriteLine("Totaal: " & totaal.ToString)

Catch err As ManagementException
Console.WriteLine("An error occurred while querying for WMI data: " &
err.Message)
End Try

I thought, yess I have finally found it . But the value resets(<-- I tink
it
resets) around 5,5 GB.

"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:16**********************************@microsof t.com...
> If you don't want per sec use RawValue. "Network connection status" and
> "Task
> Manager" display raw value of the "Packets Received Unicast"
> preformance
> counter( well almost - i dont know why "Network connection status"
> shows
> different value for the total packet sent, but the same for received)
>
> Hope this helps
>
> --
> Milosz Skalecki
> MCP, MCAD
>
>
> "newbie" wrote:
>
>> But that counter is per second.
>> How do I know what is send sinds the reboot ?
>> Or where can I find the elapsed seconds ? So I can multiply it with
>> the
>> counter bytes/sec.
>>
>>
>> "Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
>> news:2F**********************************@microsof t.com...
>> > Use PerformanceCounter class. Set CategoryName to "Network
>> > Interface"
>> > and
>> > select "Bytes Received/sec" etc.
>> >
>> > Hope this helps
>> > --
>> > Milosz Skalecki
>> > MCP, MCAD
>> >
>> >
>> > "newbie" wrote:
>> >
>> >> Hi all,
>> >>
>> >> http://www.aswin.be/nictransfer.JPG
>> >> How can I get these numbers with VB.NET ?
>> >>
>> >> I thought somewhere in WMI but I can't find them.
>> >>
>> >> Thank you,
>> >> Aswin
>> >>
>> >>
>> >>
>>
>>
>>


Jan 12 '06 #7
Put PerformanceCounter control on your form

Me.performanceCounter1.CategoryName = "Network Interface"
Me.performanceCounter1.CounterName = "Packets Received Unicast/sec"
Me.performanceCounter1.InstanceName = "Intel[R] PRO_100 VE Network
Connection - Packet Scheduler Miniport" ' it should be your ethernet device

dim lCounter as Long = performanceCounter1.NextSample().RawValue

I havent had this "around 5GB reset" problem yet :]
--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:

can you give a little example ?
What about the reset of the value around 5GB ?
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:E1**********************************@microsof t.com...
Yep,

You can use easier approach performanceCounter.NextSample().RawValue

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
You are pointing to this?

VB.NET code:

Try

Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT
BytesReceivedPersec,BytesSentPersec,BytesTotalPers ec FROM
Win32_PerfRawData_Tcpip_NetworkInterface")
Dim totaalverzonden, totaalontvangen, totaal As Int64

For Each queryObj As ManagementObject In searcher.Get()
totaalontvangen = totaalontvangen +
Convert.ToInt64(queryObj("BytesReceivedPersec"))
totaalverzonden = totaalverzonden +
Convert.ToInt64(queryObj("BytesSentPersec"))
totaal += Convert.ToInt64(queryObj("BytesTotalPersec"))
Next

Console.WriteLine("Totaalontvangen: " & totaalontvangen.ToString)
Console.WriteLine("Totaalverzonden: " & totaalverzonden.ToString)
Console.WriteLine("Totaal: " & totaal.ToString)

Catch err As ManagementException
Console.WriteLine("An error occurred while querying for WMI data: " &
err.Message)
End Try

I thought, yess I have finally found it . But the value resets(<-- I tink
it
resets) around 5,5 GB.

"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:16**********************************@microsof t.com...
> If you don't want per sec use RawValue. "Network connection status" and
> "Task
> Manager" display raw value of the "Packets Received Unicast"
> preformance
> counter( well almost - i dont know why "Network connection status"
> shows
> different value for the total packet sent, but the same for received)
>
> Hope this helps
>
> --
> Milosz Skalecki
> MCP, MCAD
>
>
> "newbie" wrote:
>
>> But that counter is per second.
>> How do I know what is send sinds the reboot ?
>> Or where can I find the elapsed seconds ? So I can multiply it with
>> the
>> counter bytes/sec.
>>
>>
>> "Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
>> news:2F**********************************@microsof t.com...
>> > Use PerformanceCounter class. Set CategoryName to "Network
>> > Interface"
>> > and
>> > select "Bytes Received/sec" etc.
>> >
>> > Hope this helps
>> > --
>> > Milosz Skalecki
>> > MCP, MCAD
>> >
>> >
>> > "newbie" wrote:
>> >
>> >> Hi all,
>> >>
>> >> http://www.aswin.be/nictransfer.JPG
>> >> How can I get these numbers with VB.NET ?
>> >>
>> >> I thought somewhere in WMI but I can't find them.
>> >>
>> >> Thank you,
>> >> Aswin
>> >>
>> >>
>> >>
>>
>>
>>


Jan 12 '06 #8
Ok idd, much easyer.

But I have still the problem. The performancecounter give you the amound of
bytes send / recieved during the past second.
I would like to know, how much bytes he has send / recieved since the
reboot.

http://www.aswin.be/nictransfer.JPG --> like that.

the rawvalue gives me idd a value wich is'nt 0 a values that increes.
But it isn't the same as in the jpg.
Do I have to calculate with the rawdata to get the actual bytes send and
recieved ?


"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:13**********************************@microsof t.com...
Put PerformanceCounter control on your form

Me.performanceCounter1.CategoryName = "Network Interface"
Me.performanceCounter1.CounterName = "Packets Received Unicast/sec"
Me.performanceCounter1.InstanceName = "Intel[R] PRO_100 VE Network
Connection - Packet Scheduler Miniport" ' it should be your ethernet
device

dim lCounter as Long = performanceCounter1.NextSample().RawValue

I havent had this "around 5GB reset" problem yet :]
--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:

can you give a little example ?
What about the reset of the value around 5GB ?
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:E1**********************************@microsof t.com...
> Yep,
>
> You can use easier approach performanceCounter.NextSample().RawValue
>
> --
> Milosz Skalecki
> MCP, MCAD
>
>
> "newbie" wrote:
>
>> You are pointing to this?
>>
>> VB.NET code:
>>
>> Try
>>
>> Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT
>> BytesReceivedPersec,BytesSentPersec,BytesTotalPers ec FROM
>> Win32_PerfRawData_Tcpip_NetworkInterface")
>> Dim totaalverzonden, totaalontvangen, totaal As Int64
>>
>> For Each queryObj As ManagementObject In searcher.Get()
>> totaalontvangen = totaalontvangen +
>> Convert.ToInt64(queryObj("BytesReceivedPersec"))
>> totaalverzonden = totaalverzonden +
>> Convert.ToInt64(queryObj("BytesSentPersec"))
>> totaal += Convert.ToInt64(queryObj("BytesTotalPersec"))
>> Next
>>
>> Console.WriteLine("Totaalontvangen: " & totaalontvangen.ToString)
>> Console.WriteLine("Totaalverzonden: " & totaalverzonden.ToString)
>> Console.WriteLine("Totaal: " & totaal.ToString)
>>
>> Catch err As ManagementException
>> Console.WriteLine("An error occurred while querying for WMI data:
>> " &
>> err.Message)
>> End Try
>>
>>
>>
>> I thought, yess I have finally found it . But the value resets(<-- I
>> tink
>> it
>> resets) around 5,5 GB.
>>
>>
>>
>>
>>
>> "Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
>> news:16**********************************@microsof t.com...
>> > If you don't want per sec use RawValue. "Network connection status"
>> > and
>> > "Task
>> > Manager" display raw value of the "Packets Received Unicast"
>> > preformance
>> > counter( well almost - i dont know why "Network connection status"
>> > shows
>> > different value for the total packet sent, but the same for
>> > received)
>> >
>> > Hope this helps
>> >
>> > --
>> > Milosz Skalecki
>> > MCP, MCAD
>> >
>> >
>> > "newbie" wrote:
>> >
>> >> But that counter is per second.
>> >> How do I know what is send sinds the reboot ?
>> >> Or where can I find the elapsed seconds ? So I can multiply it with
>> >> the
>> >> counter bytes/sec.
>> >>
>> >>
>> >> "Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
>> >> news:2F**********************************@microsof t.com...
>> >> > Use PerformanceCounter class. Set CategoryName to "Network
>> >> > Interface"
>> >> > and
>> >> > select "Bytes Received/sec" etc.
>> >> >
>> >> > Hope this helps
>> >> > --
>> >> > Milosz Skalecki
>> >> > MCP, MCAD
>> >> >
>> >> >
>> >> > "newbie" wrote:
>> >> >
>> >> >> Hi all,
>> >> >>
>> >> >> http://www.aswin.be/nictransfer.JPG
>> >> >> How can I get these numbers with VB.NET ?
>> >> >>
>> >> >> I thought somewhere in WMI but I can't find them.
>> >> >>
>> >> >> Thank you,
>> >> >> Aswin
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>


Jan 12 '06 #9
Sorry, I didn't see you have 'bytes' as unit in you Lan Status Dialog (I
reckon it's possible to change it to packets somwhere i.e. updating you
system). You can use 'Bytes received/sec' 'Bytes sent/sec' and then read
RawValue. A number you get matches to value that may be seen in 'Task
Manager->Networking' and 'netstat -e' console application. I don't know why
Lan Status bytes 'received' value differs from Performance couter equivalent.
Maybe there is an additional logic applied in 'Lan Status' program and i also
think it's driver related value (?). You can also use Win API (see WINAPI SDK
for GetIfTable, GetIfEntry) to get these values, but i'm pretty sure
Performance counter uses these functions internally (if you try it you'll see
all values are exactly the same as those returned by performance couter).

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
Ok idd, much easyer.

But I have still the problem. The performancecounter give you the amound of
bytes send / recieved during the past second.
I would like to know, how much bytes he has send / recieved since the
reboot.

http://www.aswin.be/nictransfer.JPG --> like that.

the rawvalue gives me idd a value wich is'nt 0 a values that increes.
But it isn't the same as in the jpg.
Do I have to calculate with the rawdata to get the actual bytes send and
recieved ?


"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:13**********************************@microsof t.com...
Put PerformanceCounter control on your form

Me.performanceCounter1.CategoryName = "Network Interface"
Me.performanceCounter1.CounterName = "Packets Received Unicast/sec"
Me.performanceCounter1.InstanceName = "Intel[R] PRO_100 VE Network
Connection - Packet Scheduler Miniport" ' it should be your ethernet
device

dim lCounter as Long = performanceCounter1.NextSample().RawValue

I havent had this "around 5GB reset" problem yet :]
--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:

can you give a little example ?
What about the reset of the value around 5GB ?
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:E1**********************************@microsof t.com...
> Yep,
>
> You can use easier approach performanceCounter.NextSample().RawValue
>
> --
> Milosz Skalecki
> MCP, MCAD
>
>
> "newbie" wrote:
>
>> You are pointing to this?
>>
>> VB.NET code:
>>
>> Try
>>
>> Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT
>> BytesReceivedPersec,BytesSentPersec,BytesTotalPers ec FROM
>> Win32_PerfRawData_Tcpip_NetworkInterface")
>> Dim totaalverzonden, totaalontvangen, totaal As Int64
>>
>> For Each queryObj As ManagementObject In searcher.Get()
>> totaalontvangen = totaalontvangen +
>> Convert.ToInt64(queryObj("BytesReceivedPersec"))
>> totaalverzonden = totaalverzonden +
>> Convert.ToInt64(queryObj("BytesSentPersec"))
>> totaal += Convert.ToInt64(queryObj("BytesTotalPersec"))
>> Next
>>
>> Console.WriteLine("Totaalontvangen: " & totaalontvangen.ToString)
>> Console.WriteLine("Totaalverzonden: " & totaalverzonden.ToString)
>> Console.WriteLine("Totaal: " & totaal.ToString)
>>
>> Catch err As ManagementException
>> Console.WriteLine("An error occurred while querying for WMI data:
>> " &
>> err.Message)
>> End Try
>>
>>
>>
>> I thought, yess I have finally found it . But the value resets(<-- I
>> tink
>> it
>> resets) around 5,5 GB.
>>
>>
>>
>>
>>
>> "Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
>> news:16**********************************@microsof t.com...
>> > If you don't want per sec use RawValue. "Network connection status"
>> > and
>> > "Task
>> > Manager" display raw value of the "Packets Received Unicast"
>> > preformance
>> > counter( well almost - i dont know why "Network connection status"
>> > shows
>> > different value for the total packet sent, but the same for
>> > received)
>> >
>> > Hope this helps
>> >
>> > --
>> > Milosz Skalecki
>> > MCP, MCAD
>> >
>> >
>> > "newbie" wrote:
>> >
>> >> But that counter is per second.
>> >> How do I know what is send sinds the reboot ?
>> >> Or where can I find the elapsed seconds ? So I can multiply it with
>> >> the
>> >> counter bytes/sec.
>> >>
>> >>
>> >> "Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
>> >> news:2F**********************************@microsof t.com...
>> >> > Use PerformanceCounter class. Set CategoryName to "Network
>> >> > Interface"
>> >> > and
>> >> > select "Bytes Received/sec" etc.
>> >> >
>> >> > Hope this helps
>> >> > --
>> >> > Milosz Skalecki
>> >> > MCP, MCAD
>> >> >
>> >> >
>> >> > "newbie" wrote:
>> >> >
>> >> >> Hi all,
>> >> >>
>> >> >> http://www.aswin.be/nictransfer.JPG
>> >> >> How can I get these numbers with VB.NET ?
>> >> >>
>> >> >> I thought somewhere in WMI but I can't find them.
>> >> >>
>> >> >> Thank you,
>> >> >> Aswin
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>


Jan 13 '06 #10
Elo,

Will try to come back with an example, for now try this one,
http://www.dotnetforums.net/showthre...139#post414139

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
Ok. thank you.
netstat -e --> its value resets each 5GB.
Just like the raw value of the Win32_PerfRawData_Tcpip_NetworkInterface
Really it does ! :-(
try code below, send + 5GB across the network and see again. You will see
the value has been reset. ( like netstat -e )

Imports System.Management

Try
Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT
BytesReceivedPersec,BytesSentPersec,BytesTotalPers ec FROM
Win32_PerfRawData_Tcpip_NetworkInterface")
Dim totaalverzonden, totaalontvangen, totaal As Int64
For Each queryObj As ManagementObject In searcher.Get()
totaalontvangen = totaalontvangen +
Convert.ToInt32(queryObj("BytesReceivedPersec"))
totaalverzonden = totaalverzonden +
Convert.ToInt32(queryObj("BytesSentPersec"))
totaal += Convert.ToInt64(queryObj("BytesTotalPersec"))
Next

Console.WriteLine("Totaalonvangen: " & totaalontvangen.ToString)
Console.WriteLine("Totaalverzonden: " & totaalverzonden.ToString)
Console.WriteLine("Totaal: " & totaal.ToString)

Catch err As ManagementException

Console.WriteLine("An error occurred while querying for WMI data: " &
err.Message)

End Try
Now. This morning I have found something else on the net with GetIfTable.
And now you say also to do it with GetIfTable.
I have searched for a VB.NET example ( not C-code )
But I only can find a VB6.0 application and a .NET application in C

As you can see in the JPG both codes works fine. but it isn't a VB.NET code
/ console application.
Could you help me ? I would like to output these 2 values in console.



Jan 13 '06 #11
ok thank you. I have tryed with some examples. But most examples that I can
find are VB6.0 / C
the code you gaved me is VB.NET but it doesn't work well.
It doesn't give all network interfaces / or don't give any interfaces .
On some computers it works / on others ... nothing.

but getiftable ... that's the thing I need.

Can you help me once again ?

thank you
Jan 15 '06 #12
-- BEGIN CODE --

Imports System.Reflection
Imports System.Runtime.InteropServices

Public Class IpApi

Public Const MAX_INTERFACE_NAME_LEN As Integer = 256
Public Const MAXLEN_PHYSADDR As Integer = 8
Public Const MAXLEN_IFDESCR As Integer = 256
Public Const NO_ERROR As Integer = 0
Public Const ERROR_INSUFFICIENT_BUFFER As Integer = 122

<DllImport("iphlpapi.dll", SetLastError:=True)> _
Public Shared Function GetIfTable( _
ByVal pIfTable As IntPtr, _
ByRef pdwSize As UInt32, _
ByVal bOrder As Boolean) As Integer
End Function

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Public
Structure MIB_IFROW
<MarshalAs(UnmanagedType.ByValTStr,
sizeconst:=MAX_INTERFACE_NAME_LEN)> Public wszName As String
Public dwIndex As UInt32
Public dwType As UInt32
Public dwMtu As UInt32
Public dwSpeed As UInt32
Public dwPhysAddrLen As UInt32
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=MAXLEN_PHYSADDR)>
Public bPhysAddr() As Byte
Public dwAdminStatus As UInt32
Public dwOperStatus As UInt32
Public dwLastChange As UInt32
Public dwInOctets As UInt32
Public dwInUcastPkts As UInt32
Public dwInNUcastPkts As UInt32
Public dwInDiscards As UInt32
Public dwInErrors As UInt32
Public dwInUnknownProtos As UInt32
Public dwOutOctets As UInt32
Public dwOutUcastPkts As UInt32
Public dwOutNUcastPkts As UInt32
Public dwOutDiscards As UInt32
Public dwOutErrors As UInt32
Public dwOutQLen As UInt32
Public dwDescrLen As UInt32
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=MAXLEN_IFDESCR)>
Public bDescr() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure MIB_IFTABLE
Public dwNumEntries As UInt32
Public table() As MIB_IFROW
End Structure

Public Shared Sub EnumerateInterfaces()

Dim size As UInt32
Dim result As Integer = 0
Dim buffer As IntPtr = IntPtr.Zero

result = GetIfTable(IntPtr.Zero, size, False)

Try

If (result = ERROR_INSUFFICIENT_BUFFER) Then
buffer = Marshal.AllocHGlobal(Convert.ToInt32(size))
result = GetIfTable(buffer, size, False)
Else
Throw New System.ComponentModel.Win32Exception(result)
End If

If (result <> NO_ERROR) Then
Throw New System.ComponentModel.Win32Exception(result)
Else

Dim count As Integer = Marshal.ReadInt32(buffer)
Dim ptr As Integer = buffer.ToInt32() +
Marshal.SizeOf(GetType(Integer))
Dim ifRow As MIB_IFROW
Dim description As String

For i As Integer = 1 To count
ifRow = CType(Marshal.PtrToStructure(New IntPtr(ptr),
GetType(MIB_IFROW)), MIB_IFROW)
description =
System.Text.Encoding.ASCII.GetString(ifRow.bDescr)
ptr += Marshal.SizeOf(GetType(MIB_IFROW))
Next

End If

Catch ex As Exception
Throw ex
Finally
If buffer.ToInt32() <> 0 Then
Marshal.FreeHGlobal(buffer)
End If
End Try

End Sub

End Class

-- END CODE --

Hope this helps

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
ok thank you. I have tryed with some examples. But most examples that I can
find are VB6.0 / C
the code you gaved me is VB.NET but it doesn't work well.
It doesn't give all network interfaces / or don't give any interfaces .
On some computers it works / on others ... nothing.

but getiftable ... that's the thing I need.

Can you help me once again ?

thank you

Jan 16 '06 #13
thank you,
but how can I use this class ?
dim test as new ipapi
....
?
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:71**********************************@microsof t.com...
-- BEGIN CODE --

Imports System.Reflection
Imports System.Runtime.InteropServices

Public Class IpApi

Public Const MAX_INTERFACE_NAME_LEN As Integer = 256
Public Const MAXLEN_PHYSADDR As Integer = 8
Public Const MAXLEN_IFDESCR As Integer = 256
Public Const NO_ERROR As Integer = 0
Public Const ERROR_INSUFFICIENT_BUFFER As Integer = 122

<DllImport("iphlpapi.dll", SetLastError:=True)> _
Public Shared Function GetIfTable( _
ByVal pIfTable As IntPtr, _
ByRef pdwSize As UInt32, _
ByVal bOrder As Boolean) As Integer
End Function

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Public
Structure MIB_IFROW
<MarshalAs(UnmanagedType.ByValTStr,
sizeconst:=MAX_INTERFACE_NAME_LEN)> Public wszName As String
Public dwIndex As UInt32
Public dwType As UInt32
Public dwMtu As UInt32
Public dwSpeed As UInt32
Public dwPhysAddrLen As UInt32
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=MAXLEN_PHYSADDR)>
Public bPhysAddr() As Byte
Public dwAdminStatus As UInt32
Public dwOperStatus As UInt32
Public dwLastChange As UInt32
Public dwInOctets As UInt32
Public dwInUcastPkts As UInt32
Public dwInNUcastPkts As UInt32
Public dwInDiscards As UInt32
Public dwInErrors As UInt32
Public dwInUnknownProtos As UInt32
Public dwOutOctets As UInt32
Public dwOutUcastPkts As UInt32
Public dwOutNUcastPkts As UInt32
Public dwOutDiscards As UInt32
Public dwOutErrors As UInt32
Public dwOutQLen As UInt32
Public dwDescrLen As UInt32
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=MAXLEN_IFDESCR)>
Public bDescr() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure MIB_IFTABLE
Public dwNumEntries As UInt32
Public table() As MIB_IFROW
End Structure

Public Shared Sub EnumerateInterfaces()

Dim size As UInt32
Dim result As Integer = 0
Dim buffer As IntPtr = IntPtr.Zero

result = GetIfTable(IntPtr.Zero, size, False)

Try

If (result = ERROR_INSUFFICIENT_BUFFER) Then
buffer = Marshal.AllocHGlobal(Convert.ToInt32(size))
result = GetIfTable(buffer, size, False)
Else
Throw New System.ComponentModel.Win32Exception(result)
End If

If (result <> NO_ERROR) Then
Throw New System.ComponentModel.Win32Exception(result)
Else

Dim count As Integer = Marshal.ReadInt32(buffer)
Dim ptr As Integer = buffer.ToInt32() +
Marshal.SizeOf(GetType(Integer))
Dim ifRow As MIB_IFROW
Dim description As String

For i As Integer = 1 To count
ifRow = CType(Marshal.PtrToStructure(New IntPtr(ptr),
GetType(MIB_IFROW)), MIB_IFROW)
description =
System.Text.Encoding.ASCII.GetString(ifRow.bDescr)
ptr += Marshal.SizeOf(GetType(MIB_IFROW))
Next

End If

Catch ex As Exception
Throw ex
Finally
If buffer.ToInt32() <> 0 Then
Marshal.FreeHGlobal(buffer)
End If
End Try

End Sub

End Class

-- END CODE --

Hope this helps

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
ok thank you. I have tryed with some examples. But most examples that I
can
find are VB6.0 / C
the code you gaved me is VB.NET but it doesn't work well.
It doesn't give all network interfaces / or don't give any interfaces .
On some computers it works / on others ... nothing.

but getiftable ... that's the thing I need.

Can you help me once again ?

thank you

Jan 17 '06 #14
Sorry but I didn't have time to finish it. It's an example how to implement
it and i'm pretty sure you can proceed from this point yourself.
--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
thank you,
but how can I use this class ?
dim test as new ipapi
....
?
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:71**********************************@microsof t.com...
-- BEGIN CODE --

Imports System.Reflection
Imports System.Runtime.InteropServices

Public Class IpApi

Public Const MAX_INTERFACE_NAME_LEN As Integer = 256
Public Const MAXLEN_PHYSADDR As Integer = 8
Public Const MAXLEN_IFDESCR As Integer = 256
Public Const NO_ERROR As Integer = 0
Public Const ERROR_INSUFFICIENT_BUFFER As Integer = 122

<DllImport("iphlpapi.dll", SetLastError:=True)> _
Public Shared Function GetIfTable( _
ByVal pIfTable As IntPtr, _
ByRef pdwSize As UInt32, _
ByVal bOrder As Boolean) As Integer
End Function

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Public
Structure MIB_IFROW
<MarshalAs(UnmanagedType.ByValTStr,
sizeconst:=MAX_INTERFACE_NAME_LEN)> Public wszName As String
Public dwIndex As UInt32
Public dwType As UInt32
Public dwMtu As UInt32
Public dwSpeed As UInt32
Public dwPhysAddrLen As UInt32
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=MAXLEN_PHYSADDR)>
Public bPhysAddr() As Byte
Public dwAdminStatus As UInt32
Public dwOperStatus As UInt32
Public dwLastChange As UInt32
Public dwInOctets As UInt32
Public dwInUcastPkts As UInt32
Public dwInNUcastPkts As UInt32
Public dwInDiscards As UInt32
Public dwInErrors As UInt32
Public dwInUnknownProtos As UInt32
Public dwOutOctets As UInt32
Public dwOutUcastPkts As UInt32
Public dwOutNUcastPkts As UInt32
Public dwOutDiscards As UInt32
Public dwOutErrors As UInt32
Public dwOutQLen As UInt32
Public dwDescrLen As UInt32
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=MAXLEN_IFDESCR)>
Public bDescr() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure MIB_IFTABLE
Public dwNumEntries As UInt32
Public table() As MIB_IFROW
End Structure

Public Shared Sub EnumerateInterfaces()

Dim size As UInt32
Dim result As Integer = 0
Dim buffer As IntPtr = IntPtr.Zero

result = GetIfTable(IntPtr.Zero, size, False)

Try

If (result = ERROR_INSUFFICIENT_BUFFER) Then
buffer = Marshal.AllocHGlobal(Convert.ToInt32(size))
result = GetIfTable(buffer, size, False)
Else
Throw New System.ComponentModel.Win32Exception(result)
End If

If (result <> NO_ERROR) Then
Throw New System.ComponentModel.Win32Exception(result)
Else

Dim count As Integer = Marshal.ReadInt32(buffer)
Dim ptr As Integer = buffer.ToInt32() +
Marshal.SizeOf(GetType(Integer))
Dim ifRow As MIB_IFROW
Dim description As String

For i As Integer = 1 To count
ifRow = CType(Marshal.PtrToStructure(New IntPtr(ptr),
GetType(MIB_IFROW)), MIB_IFROW)
description =
System.Text.Encoding.ASCII.GetString(ifRow.bDescr)
ptr += Marshal.SizeOf(GetType(MIB_IFROW))
Next

End If

Catch ex As Exception
Throw ex
Finally
If buffer.ToInt32() <> 0 Then
Marshal.FreeHGlobal(buffer)
End If
End Try

End Sub

End Class

-- END CODE --

Hope this helps

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
ok thank you. I have tryed with some examples. But most examples that I
can
find are VB6.0 / C
the code you gaved me is VB.NET but it doesn't work well.
It doesn't give all network interfaces / or don't give any interfaces .
On some computers it works / on others ... nothing.

but getiftable ... that's the thing I need.

Can you help me once again ?

thank you


Jan 17 '06 #15
Hi,

I've found it to use your class. the enumerate subroutine..
the for i to count ... there I was able to find all the information I
want..
But, :-( he says in 4GB . Its inpossible because MSTCP loopback is 3,4GB.
+ only 1 GB out ?
server is online for 10days now. I guess he has send and recieved more then
20 GB .
console output from program:

Intel(R) PRO/1000 MT Desktop Adapter
inunpackets: 83.970.949 outunpackets: 51.885.545
inbytes: 4.092.707.942 outbytes: 999.628.193

MS TCP Loopback interface
inunpackets: 16.793.738 outunpackets: 16.779.370
inbytes: 3.428.810.751 outbytes: 3.428.810.751
And with you ?
If you send more then 10GB . The numbers are still correct ?

the subroutine enumeratinterfaces in your class, I have edited a little so
it outputs the info to the console.
your class:

Imports System.Reflection
Imports System.Runtime.InteropServices
Module Module1
Sub Main()
IpApi.EnumerateInterfaces()
Console.ReadLine()
End Sub

Public Class IpApi

.......................

See other post

.......................

Public Shared Sub EnumerateInterfaces()

Dim size As UInt32

Dim result As Integer = 0

Dim buffer As IntPtr = IntPtr.Zero

result = GetIfTable(IntPtr.Zero, size, False)

Try

If (result = ERROR_INSUFFICIENT_BUFFER) Then

buffer = Marshal.AllocHGlobal(Convert.ToInt32(size))

result = GetIfTable(buffer, size, False)

Else

Throw New System.ComponentModel.Win32Exception(result)

End If

If (result <> NO_ERROR) Then

Throw New System.ComponentModel.Win32Exception(result)

Else

Dim count As Integer = Marshal.ReadInt32(buffer)

Dim ptr As Integer = buffer.ToInt32() + Marshal.SizeOf(GetType(Integer))

Dim ifRow As MIB_IFROW

Dim description As String

Dim bytesin, bytesout As String

Dim dummy As Integer

For i As Integer = 1 To count

ifRow = CType(Marshal.PtrToStructure(New IntPtr(ptr), GetType(MIB_IFROW)),
MIB_IFROW)

description = System.Text.Encoding.ASCII.GetString(ifRow.bDescr)

ptr += Marshal.SizeOf(GetType(MIB_IFROW))

description = Trim(Replace(Replace(Trim(description), Chr(10), ""), Chr(13),
""))

Console.WriteLine(description)

dummy = 1

bytesin = ""

Do While dummy <= ifRow.dwInOctets.ToString.Length

If dummy = 4 Or dummy = 7 Or dummy = 10 Or dummy = 13 Or dummy = 16 Or dummy
= 19 Or dummy = 22 Then

bytesin = "." & bytesin

End If

If ifRow.dwInOctets.ToString.Length > 2 Then

bytesin =
ifRow.dwInOctets.ToString.Substring(ifRow.dwInOcte ts.ToString.Length -
dummy, 1) & bytesin

Else

bytesin = ifRow.dwInOctets.ToString

End If

dummy += 1

Loop

dummy = 1

bytesout = ""

Do While dummy <= ifRow.dwOutOctets.ToString.Length

If dummy = 4 Or dummy = 7 Or dummy = 10 Or dummy = 13 Or dummy = 16 Or dummy
= 19 Or dummy = 22 Then

bytesout = "." & bytesout

End If

If ifRow.dwOutOctets.ToString.Length > 2 Then

bytesout =
ifRow.dwOutOctets.ToString.Substring(ifRow.dwOutOc tets.ToString.Length -
dummy, 1) & bytesout

Else

bytesout = ifRow.dwOutOctets.ToString

End If

dummy += 1

Loop

Console.WriteLine("inp: " & ifRow.dwInUcastPkts.ToString & " outp: " &
ifRow.dwOutUcastPkts.ToString)

Console.WriteLine("in: " & bytesin & " out: " & bytesout)

Next

End If

Catch ex As Exception

Throw ex

Finally

If buffer.ToInt32() <> 0 Then

Marshal.FreeHGlobal(buffer)

End If

End Try

End Sub

..............;;

see other post.
Jan 19 '06 #16
I think I've found the problem.

The UInt32 value type represents unsigned integers with values ranging from
0 to 4,294,967,295.

thats why i never get a value that is more then 4GB !

Is there a counter that counts the overflows ?

bytesout = overflowcounter * 4,294,967,295 + currentUINT32counter.

that would be the correct value...
Jan 19 '06 #17
hm I don't think it overflows..
because inoctets / outoctets are DWORDS.

But in VB.NET you say that they are uint32.
But if I change that inoctets in ifrow to uint64
I really get a wrong value.
Jan 19 '06 #18
DWORD in WINAPI is exactly the same what uint32 is in .NET. Do not change
anything in this structure :D. Could you check if the Task Manager value
restarts too (run Task Magaer, go to Newtorking Tab, select
Menu->View->Select Columns)? If it does, it means Lan Connection Status
counts value overflows internally. If you disable and enable connection value
restarts to 0.

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
hm I don't think it overflows..
because inoctets / outoctets are DWORDS.

But in VB.NET you say that they are uint32.
But if I change that inoctets in ifrow to uint64
I really get a wrong value.

Jan 19 '06 #19
yes it also resets.
So i have to manually keep the overflow coints. and manually count in
strings. so i never get an overflow.
Thank you for helping me !.
btw, SNMP trap.. also resets on 4GB.

Is there a way to get the internal overflow count of the status lan ?
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:09**********************************@microsof t.com...
DWORD in WINAPI is exactly the same what uint32 is in .NET. Do not change
anything in this structure :D. Could you check if the Task Manager value
restarts too (run Task Magaer, go to Newtorking Tab, select
Menu->View->Select Columns)? If it does, it means Lan Connection Status
counts value overflows internally. If you disable and enable connection
value
restarts to 0.

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
hm I don't think it overflows..
because inoctets / outoctets are DWORDS.

But in VB.NET you say that they are uint32.
But if I change that inoctets in ifrow to uint64
I really get a wrong value.

Jan 20 '06 #20
Dont know :( Try registry or assembler :)
--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
yes it also resets.
So i have to manually keep the overflow coints. and manually count in
strings. so i never get an overflow.
Thank you for helping me !.
btw, SNMP trap.. also resets on 4GB.

Is there a way to get the internal overflow count of the status lan ?
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> schreef in bericht
news:09**********************************@microsof t.com...
DWORD in WINAPI is exactly the same what uint32 is in .NET. Do not change
anything in this structure :D. Could you check if the Task Manager value
restarts too (run Task Magaer, go to Newtorking Tab, select
Menu->View->Select Columns)? If it does, it means Lan Connection Status
counts value overflows internally. If you disable and enable connection
value
restarts to 0.

--
Milosz Skalecki
MCP, MCAD
"newbie" wrote:
hm I don't think it overflows..
because inoctets / outoctets are DWORDS.

But in VB.NET you say that they are uint32.
But if I change that inoctets in ifrow to uint64
I really get a wrong value.


Jan 20 '06 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: John Roth | last post by:
PEP 263 is marked finished in the PEP index, however I haven't seen the specified Phase 2 in the list of changes for 2.4 which is when I expected it. Did phase 2 get cancelled, or is it just not...
9
by: Brian Roberts | last post by:
I have a command line Python program that sometimes takes a bit (several minutes) to run. I want to provide an optional method for an impatient user (me!) to check the status of the program. The...
8
by: Noel Volin | last post by:
Anyone who can help here is much appreciated. I am trying to programmatically log onto a website. I am using the code provided in VS for the AuthenticationManager Class example (...
0
by: Eddy_w | last post by:
Hello, I try to ping from my mobile device with a wireless connection to my pc. I found the class clsping on the internet and it works perfect with application from pc to pc but when i use it...
1
by: rs | last post by:
how I the client tell the server that the socket is closed? or this there an even that informs the server that the clients socket is close? Oh, I am using vb.net 2003 Thanks
14
by: ahlongxp | last post by:
Hi, everyone, I'm implementing a simple client/server protocol. Now I've got a situation: client will send server command,header paires and optionally body. server checks headers and decides...
5
by: This | last post by:
I have a pretty basic emailing script that sends a relatively small number (150) of html emails. The emails are compiled, personalised from a mysql db subscribers list, and sent using mail() -...
0
by: T1Stuff | last post by:
I have programmed a simple synchronous socket server app in vb.net to communicate and receive messages from our data integration tool that works well with all our other systems. The program I...
0
by: Xionbox | last post by:
Hello everybody, The error I have seems very easy to solve, but for some odd reason I can't seem to solve it. Anyways, here's my "setup". I created a server running on localhost:1200 (telnet...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.