Incoming Outgoing Bandwidth Traffic

  • Thread starter Thread starter Smartbomb
  • Start date Start date
S

Smartbomb

Hey guys and gals, I was wondering how I could do a bandwidth traffice moniter on incoming and outgoing traffic on a network card. is there a simple way to moniter and record the traffic? I know of performance counter but did not get it working. Thanks for the help in advance. -Smartbomb
 
Smartbomb said:
Hey guys and gals, I was wondering how I could do a bandwidth traffice
moniter >on incoming and outgoing traffic on a network card. is there a
simple way to >moniter and record the traffic? I know of performance counter
but did not get it >working. Thanks for the help in advance. -Smartbomb

Sounds like you have the answer to your own question: use the perfomance
counters.

Now what problem were you having?

David
 
Well I would put it into the program, fill out the information in the
properties section and well from there I wasn't sure how to have it
measure the network card's activity. I tired many ways but i just could
not get the counter to count heh. Any help with the counter would be
apperciated. Thanks for the quick reply and thanks again in advance.
 
Howdy SmartBomb,

What performance counter are you using? Do you know where there is a list
of the available categories and counters?

Regards,
Fergus
 
hi Fergus, i'm using the performance counter that is found under
Toolbox->Components->Performance Counter. And sorry I do not know a
list. -Smartbomb
 
Fergus Cooney said:
Howdy SmartBomb,

What performance counter are you using? Do you know where there is a list
of the available categories and counters?

Regards,
Fergus

Run Perfmon.exe to see all the available counters.

And here's a sample for network monitoring.
It uses the network interface, you might want to monitor a different one or
all of them.


David



Imports System.Diagnostics
Module Module1

Sub Main()

Dim pc As New PerformanceCounterCategory("Network Interface")
Dim instance As String = pc.GetInstanceNames(0)
Dim bs As New PerformanceCounter("Network Interface", "Bytes Sent/sec",
instance)
Dim br As New PerformanceCounter("Network Interface", "Bytes
Received/sec", instance)

Console.WriteLine("Monitoring " & instance)
Do
Dim kbSent As Integer = bs.NextValue() / 1024
Dim kbReceived As Integer = br.NextValue() / 1024
Console.WriteLine(String.Format("Bytes Sent {0}k Bytes Received {1}k",
kbSent, kbReceived))
Threading.Thread.Sleep(1000)
Loop

End Sub

End Module
 
Hi SmartBomb,

I didn't mean which Control, I meant which category and counter. :-)

However I found out for myself where the list is. I think it may depend on
what version of VS you have, but in the Server Explorer (View menu) there is
the complete list. Woohoo! It may be that you are choosing the wrong counter
or that a combination would serve your needs.
 
Thanks David and Fergus! The code helped a lot. and the counter list
(which i did not know exsited) helped quite a bit as well. I was able to
piece them together with some edits and finally get it working! Thanks
guys!
 
Back
Top