tags:

views:

278

answers:

2

I'm trying to figure out how I can determine, through C# code, if my communication with a remote machine uses the WLAN card or a wired NIC on the local machine.

For instance the remote machine is accessed through either ODBC connection to a SQL database, or a UNC fileshare. How can I detect if the communication is done through WLAN or wired LAN?

The purpose is to warn user that the application does not like communicating with the remote machine over WLAN.

I'm open for both regular C#+.NET Framework solutions, but can also use WMI if it helps.

The next step is to determine if the access is over a WAN/VPN connection, but the primary question is the first one.

Frode

+1  A: 

This sounds highly relevant, especially the Wireless80211 enum value.

unwind
Yes, that does look relevant.However, I need to figure out which card is used when communicating with the remote machine. Just detecting that the local machine has a WLAN card isn't enough.
Frode Lillerud
A: 

Use the network information types/WMI to get routing information having done a name lookup to get all the IP addresses of the remote machine.

However, this will only ever be a guesstimate. It is quite possible for packets from your machine to go over a wired LAN, and return packets to go across the WLAN. Because it is the routing table on the remote system that determines which interface it uses and this is a local resource.

Richard