This project is read-only.

Multiple Network Adapters / Network Connection Speed

Aug 17, 2012 at 1:49 PM
Edited Aug 17, 2012 at 1:49 PM


1) Finally created my PPPOE dialer. Now, as I always want to improve the code, comes the question: If I have 2 or more NICs, Is there a way for me to select which one will do the dotRas dialing?

2) I did some research on the discussion list and what I saw did not have a way dotRas "native" to control the speed of download / upload connection, as well as amount of data traffic. For this, I have to use the class "System.Net.NetworkInformation", correct?

Aug 18, 2012 at 5:36 PM

1) DotRas doesn't handle this. If there's something in Windows that'll do it, you'll need to track that down. Could have something to do with the routing tables, not sure though. Just a theory.

2) DotRas is simply the thing that gets Windows to connect to the remote network, download managers typically have logic built into them to control the speed at which they download the data. They don't change the upload / download rate of the connection itself but rather change the speed at which they download the data. As for what you need to accomplish that in your project, you're gonna be on your own there.

Hope that helps!

Aug 20, 2012 at 1:07 PM
Edited Aug 20, 2012 at 1:08 PM


After talking with other people, I saw to my project is not necessary that control of the network cards. For now, this will not be implemented.

About the connection speed, this would not be good right now. The interesting thing for me is to control data traffic connection. That I got this:

Dim devices() = NetworkInterface.GetAllNetworkInterfaces()
Dim device As NetworkInterface

For Each device In devices
     Dim received As Long = device.GetIPv4Statistics().BytesReceived()
     Dim sent As Long = device.GetIPv4Statistics().BytesSent()

It has some controls over what I do inside the loop, but basically how it works.


Thanks for the help.

Aug 20, 2012 at 6:19 PM

If all you're trying to do is retrieve the bytes sent and received, you can use DotRas to pull that information for you. For example:

using DotRas;
using System.Linq;

RasConnection connection = RasConnection.GetActiveConnections().Where(c => c.Name = "My Connection").FirstOrDefault();
if (connection != null)
    RasLinkStatistics stats = connection.GetConnectionStatistics();
    if (stats != null)
        long received = stats.BytesRecieved;
        long sent = stats.BytesTransmitted;

This will find your active connection in the list of active connections, and then request the connection statistics from Windows which you can then use.