Nofal


How can I check the connection speed by code.


Re: How can I check the Internet connection speed via code?

nogChoco


First, get the NetworkInterface that is connected to the internet. Check for the right one when you get them all -- in the example: zAllNICs variable-array stores all the networkinterfaces, I'm assuming Item 0 (Private theNIC As NetworkInterface = zAllNICs(0)) is the right one, but that will not always work.

Once you have the right NetworkInterface, you can check its properties to see how many bytes in total have been received/sent. If you put some time-points around that in code, you can calculate the speed in bytes per second (or whatever units you want).

Here's a (hopefully) working example, but note that I scrambled it together from my own speedgraph app that I'm building, so it may not be the most readable code.

For Downloadspeed: zDownloadSpeedTrue_UploadSpeedFalse As Boolean = True
For Uploadspeed: zDownloadSpeedTrue_UploadSpeedFalse As Boolean = False

Also note that you need to browse the internet to see changes to the speed. Setting the timer's interval (in milliseconds) to a higher value will make it have less peaks. Here's the code:



Re: How can I check the Internet connection speed via code?

Nofal

Thank you

Nofal