Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If two WiFi networks exist with similar SSIDs, how can you distinguish between the two in code? [duplicate]

I'm writing a small network management tool. In order to pull out the details for various WiFi networks, I'm making calls to the wlanapi.dll, WlanGetProfile(...) API method to get the profile information for each available WiFi network.

Assuming two local WiFi networks have similar SSIDs, how can I query information on these two networks and distinguish between the two when I present the information to the user?

I am writing my app in C#, however, generalized details that are not code-specific can be provided if they will give me the answers that I needed. However, I'm tagging this as C#/.Net because if there is a way to get this information using native .Net libraries, I'd appreciate C# code samples.

like image 604
RLH Avatar asked Apr 04 '18 17:04

RLH


People also ask

What happens if 2 SSIDs are the same?

Two identically named SSIDs with the same password will allow your device to connect to either, without having to add any extra networks on your devices. If both routers are broadcasting from the same location, the expected behaviour will vary depending on device.

Why do I have two SSIDs?

Normally, multiple SSIDs are used to provide different types of wireless network access to different device types and user classes. The downside of enabling more SSIDs is that it creates more channel utilization due to overhead.

What happens if I have 2 Wi-Fi networks?

You could have one ISP and multiple routers, this is not advisable because having multiple wireless routers in a small area will likely result in interference which will result in a WORSE signal as opposed to a better one.

Can 2.4 g and 5g have same SSID?

When setting up a Wi-Fi connection in the 2.4 GHz and 5 GHz dual-band Keenetic models, the same network name (SSID) and password are used by default. This feature was made for the convenience of users. With the same SSID in 2.4 GHz and 5 GHz bands, client devices will not need to reconnect.


2 Answers

There is no prolem with detecting few networks with the same SSID because they have different MACs.

However it looks there is no way to connect to selected one because no way to specify a MAC when connectiong.

like image 159
Mike Petrichenko Avatar answered Sep 28 '22 02:09

Mike Petrichenko


This Code project sample so the same Link : A-Vista-Wireless-Network-Scanner

enter image description here

Process proc = new Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.FileName = "netsh";
proc.StartInfo.Arguments = "wlan show networks mode=bssid";
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
output = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();

Connect with mac:

//// Connects to a known network with WEP security
string profileName = "Cheesecake"; // this is also the SSID
string mac = "52544131303235572D454137443638";
string key = "hello";
string profileXml = string.Format("<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><hex>{1}</hex><name>{0}</name></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>open</authentication><encryption>WEP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>networkKey</keyType><protected>false</protected><keyMaterial>{2}</keyMaterial></sharedKey><keyIndex>0</keyIndex></security></MSM></WLANProfile>", profileName, mac, key);

wlanIface.SetProfile(Wlan.WlanProfileFlags.AllUser, profileXml, true);
wlanIface.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, profileName);
like image 39
Jophy job Avatar answered Sep 28 '22 00:09

Jophy job