Re: Bandwidth Monitor issue
Try this without downloading
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
Dim ipstat As IPGlobalStatistics = properties.GetIPv4GlobalStatistics()
TextBox1.Text = ipstat.ReceivedPackets.ToString("N0")
End Sub
Now, how big are the packets?
Re: Bandwidth Monitor issue
The number shows 662,212 and changes by about 1-2 every second or so without downloading
Re: Bandwidth Monitor issue
For bytes I think you need IPv4InterfaceStatistics.
Re: Bandwidth Monitor issue
Hrm, I'll try to set that up. Meanwhile I don't suppose you have an example I could work from would you?
Thank you by the way for the assistance, it is appreciated :)
Re: Bandwidth Monitor issue
Look at my signature> Network Info Probably more than you wanted, but I think rcv bytes is there.
Re: Bandwidth Monitor issue
Oh excellent, I will reply back shortly to let you know if this fixed my problem.
Thanks again
Re: Bandwidth Monitor issue
Hello again, I think I'm close to getting this fixed but I'm having a hard time figuring out how to single out the adapter I need instead of using the for each statement. How can request data specifically from networkcard.name blah
This is what I'm using to sift now for the card
Code:
For Each networkCard As System.Net.NetworkInformation.NetworkInterface _
In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
Dim ipstats As System.Net.NetworkInformation.IPv4InterfaceStatistics = networkCard.GetIPv4Statistics
if networkcard.name = uxAdapterSelectionCmbo.text then
dostuffhere
end if
next
Re: Bandwidth Monitor issue
I think you have to iterate through the interfaces to find the one you want.
Re: Bandwidth Monitor issue
Ah, that would explain why I was having trouble figuring out the solution for it lol. Thanks :)
Re: Bandwidth Monitor issue
Code:
Dim myIntf As NetworkInterface
For Each networkCard As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces
If networkCard.Description.Contains("Wireless") Then
myIntf = networkCard
Exit For
End If
Next
If Not myIntf Is Nothing Then
Dim foo As IPv4InterfaceStatistics = myIntf.GetIPv4Statistics
Debug.WriteLine(foo.BytesReceived.ToString)
End If
Re: Bandwidth Monitor issue
Once again I appreciate the help with my issues. I tested the data I'm getting with bytes vs what I'm transferring again and seem to still be coming up short with the total transferred by almost half.
I'm not quite sure what I'm missing here other than there are some other packets I'm not adding in someplace I need to be adding. If I download 93 megs of data I should be able to see that result in my program with what it caught but I'm not.
Do you have any other suggestions on what I could possibly be missing? Should I be calculating more than just bytesreceived?
Sorry to be so much trouble :\
Thanks again
Re: Bandwidth Monitor issue
I wouldn't be surprised to see the number higher, but not lower. How do you get the file size? Are you right clicking Properties of the file?
Re: Bandwidth Monitor issue
Yep, says it's exactly 98.1 megs
Re: Bandwidth Monitor issue
I downloaded a PDF of about 400KB. The following showed about 800KB.
Code:
Imports System.Net.NetworkInformation
Public Class Form1
Dim myIntf As NetworkInterface
Dim strtBytes As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each networkCard As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces
If networkCard.Description.Contains("Wireless") Then
myIntf = networkCard
Exit For
End If
Next
Timer1.Interval = 250
End Sub
Dim endBytes As Long
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Not myIntf Is Nothing Then
Dim foo As IPv4InterfaceStatistics = myIntf.GetIPv4Statistics
endBytes = foo.BytesReceived
End If
TextBox1.Text = (endBytes - strtBytes).ToString("N0")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Timer1.Enabled Then
Timer1.Stop()
Else
Timer1.Start()
If Not myIntf Is Nothing Then
Dim foo As IPv4InterfaceStatistics = myIntf.GetIPv4Statistics
strtBytes = foo.BytesReceived
End If
End If
End Sub
End Class
Re: Bandwidth Monitor issue
You're right, it must be the way I'm putting together my data. I'm going to play with this some more and be off for the night. Thanks again for helping try to find the problem with my program. Looking at how you handled the data I think I see where my problem is.
Take it easy, again I appreciated it.
Re: Bandwidth Monitor issue
Remember to mark the thread resolved when it is.