简体   繁体   中英

Detection of connection and speed of Cellular Network vs. 802.11 and Ethernet? C# .Net

I am working on a program which will be used on mobile devices (Full Windows install) that may have 3G connectivity. If the particular device does have 3G connectivity, we would like to take advantage of it. However, the program should be able to prioritize communication based on what type of connection and speed are currently available.

I am able to get a list of the network interfaces using System.Net.NetworkInformation.NetworkInterface, but is there any good way to see if the interface is cell data, wireless, or regular ethernet as well as the available speed (particularly in the case of cell data)?

This will list all of the network connections that are currently up. It should be a place to start.

var interfaces = NetworkInterface.GetAllNetworkInterfaces()
    .Where(n => n.OperationalStatus == OperationalStatus.Up)
    .Select(n => new { Nic = n, Speed = n.Speed });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM