public bool ConnectToAP(string profilename)
        {
            // Before starting the connect, perform a scan
            Log("Triggering a scan");
            try
            {
                Api.Scan(TestInterface.Id, false, new TimeSpan(0, 0, 10));
            }
            catch (Exception e)
            {
                // This error is OK
                Log("Failed to do a scan. Please refer to traces for details. " + e.Message);
            }

            Log("Connecting to " + profilename);
            try
            {
                Api.ProfileConnect(TestInterface.Id, profilename, new TimeSpan(0, 0, 30));
            }
            catch (Exception e)
            {
                LogError("Failed to do a profile connect to ssid " + profilename + " with a timeout of 30s. Please refer to traces for details. " + e.Message);
                return(false);
            }
            try
            {
                Helpers.WaitForFullNetworkConnectivity(TestInterface.Id, DefaultTimeOuts.DefaultDHCPTimeout, RoamingConfiguration.ServiceAPChannelAddress, EchoPort, EchoByteStream);
            }
            catch (Exception e)
            {
                LogError("An Error was encountered when waiting for full L3 connectivity, after connecting to " + profilename + " with a timeout of " + DefaultTimeOuts.DefaultDHCPTimeout + "ms. Please refer to traces for details." + e.Message);
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public void Scan()
        {
            Log("Scan Test Configuration Parameters: ");
            Log(m_AP1Config24GHz.GetTestParameter());
            Log(m_AP1Config5GHz.GetTestParameter());
            Log(m_AP2Config24GHz.GetTestParameter());
            Log(m_AP2Config5GHz.GetTestParameter());

            SetupRouters();
            // Turn on all Radios
            Log("Turning on all radios");
            AC.SetRadio24GHzState(routers[0], true);
            AC.SetRadio24GHzState(routers[1], true);
            AC.SetRadio5GHzState(routers[0], true);
            AC.SetRadio5GHzState(routers[1], true);

            LogMajor("Turning on Airplane Mode");
            Api.SetRadioState(TestInterface, false);

            EventHandler <EventArrivedEventArgs> ETWCallback = null;

            ETWCallback = (object sender, EventArrivedEventArgs properties) =>
            {
                LogEtwEvent(properties);
            };

            var wlanEtwWatcher = new WlanEtwWatcher();

            wlanEtwWatcher.EventArrived += ETWCallback;
            Log("Start ETW Tracing");
            wlanEtwWatcher.Start();

            bool Radio_0_24Ghz_Found = false;
            bool Radio_1_24Ghz_Found = false;
            bool Radio_0_5Ghz_Found  = false;
            bool Radio_1_5Ghz_Found  = false;

            string Reason_Radio_0_24Ghz_Found = null;
            string Reason_Radio_1_24Ghz_Found = null;
            string Reason_Radio_0_5Ghz_Found  = null;
            string Reason_Radio_1_5Ghz_Found  = null;

            try
            {
                Log("Sleeping for a second");
                Wlan.Sleep(1 * 1000); // 1s

                LogMajor("Turning off Airplane Mode");
                Api.SetRadioState(TestInterface, true);

                for (int i = 0; i < 4; i++)
                {
                    Log("Scan Iteration " + i);

                    if (i == 0)
                    {
                        // First scan is always with a flush so that we dont get old data
                        LogMajor("Calling (public) scan with flush");
                        Api.Scan(TestInterface.Id, true, new TimeSpan(0, 0, 10));
                    }
                    else if (ScanningConfiguration.IssueMulitpleScans == true)
                    {
                        // Additional scans are without flush
                        LogMajor("Calling (internal) scan without flush");
                        Api.Scan(TestInterface.Id, false, new TimeSpan(0, 0, 10));
                    }

                    // If any network is marked hidden, we need to specifically search for those
                    for (int j = 0; j < 2; j++)
                    {
                        if (APConfigs[j].BeaconEnabled_24GHZ == false)
                        {
                            LogMajor("Calling (public) scan for " + APConfigs[j].SSID_24GHZ);
                            Api.Scan(TestInterface.Id, false, APConfigs[j].SSID_24GHZ, new TimeSpan(0, 0, 10));
                        }
                        if (APConfigs[j].BeaconEnabled_5GHZ == false)
                        {
                            LogMajor("Calling (public) scan for " + APConfigs[j].SSID_5GHZ);
                            Api.Scan(TestInterface.Id, false, APConfigs[j].SSID_5GHZ, new TimeSpan(0, 0, 10));
                        }
                    }

                    if (!Radio_0_24Ghz_Found)
                    {
                        LogMajor("Scan : Locating " + APConfigs[0].SSID_24GHZ + " in bssid list");
                        if (Helpers.ValidateNetworkVisible(Api, APConfigs[0], false, out Reason_Radio_0_24Ghz_Found))
                        {
                            LogMajor(APConfigs[0].SSID_24GHZ + "found in scan list ");
                            Radio_0_24Ghz_Found = true;
                        }
                        else
                        {
                            LogMajor("ValidateNetworkVisible failed for " + APConfigs[0].SSID_24GHZ);
                        }
                    }

                    if (!Radio_1_24Ghz_Found)
                    {
                        LogMajor("Scan : Locating " + APConfigs[1].SSID_24GHZ + " in bssid list");
                        if (Helpers.ValidateNetworkVisible(Api, APConfigs[1], false, out Reason_Radio_1_24Ghz_Found))
                        {
                            LogMajor(APConfigs[1].SSID_24GHZ + "found in scan list ");
                            Radio_1_24Ghz_Found = true;
                        }
                        else
                        {
                            LogMajor("ValidateNetworkVisible failed for " + APConfigs[1].SSID_24GHZ);
                        }
                    }

                    if (!ScanningConfiguration.DeviceSupports5Ghz)
                    {
                        if (Radio_0_24Ghz_Found && Radio_1_24Ghz_Found)
                        {
                            LogMajor("Scan: Located all routers");
                            return;
                        }
                        else
                        {
                            LogMajor("Scan: Not yet located all routers ");
                            LogMajor("Router 0 2.4Ghz Found =" + Radio_0_24Ghz_Found);
                            LogMajor("Router 1 2.4Ghz Found =" + Radio_1_24Ghz_Found);
                            continue; // skip 5Ghz
                        }
                    }



                    if (!Radio_0_5Ghz_Found)
                    {
                        LogMajor("Scan : Locating " + APConfigs[0].SSID_5GHZ + " in bssid list");
                        if (Helpers.ValidateNetworkVisible(Api, APConfigs[0], true, out Reason_Radio_0_5Ghz_Found))
                        {
                            LogMajor(APConfigs[0].SSID_5GHZ + " found in scan list");
                            Radio_0_5Ghz_Found = true;
                        }
                        else
                        {
                            LogMajor("ValidateNetworkVisible failed for " + APConfigs[0].SSID_5GHZ);
                        }
                    }

                    if (!Radio_1_5Ghz_Found)
                    {
                        LogMajor("Scan : Locating " + APConfigs[1].SSID_5GHZ + " in bssid list");
                        if (Helpers.ValidateNetworkVisible(Api, APConfigs[1], true, out Reason_Radio_1_5Ghz_Found))
                        {
                            LogMajor(APConfigs[1].SSID_5GHZ + " found in scan list");
                            Radio_1_5Ghz_Found = true;
                        }
                        else
                        {
                            LogMajor("ValidateNetworkVisible failed for " + APConfigs[1].SSID_5GHZ);
                        }
                    }

                    if (Radio_0_24Ghz_Found &&
                        Radio_1_24Ghz_Found &&
                        Radio_0_5Ghz_Found &&
                        Radio_1_5Ghz_Found)
                    {
                        LogMajor("Scan: Located all routers");
                        return;
                    }

                    LogMajor("Scan: Not yet located all routers ");
                    LogMajor("Router 0 2.4Ghz Found =" + Radio_0_24Ghz_Found);
                    LogMajor("Router 1 2.4Ghz Found =" + Radio_1_24Ghz_Found);
                    LogMajor("Router 0 5Ghz Found =" + Radio_0_5Ghz_Found);
                    LogMajor("Router 1 5Ghz Found =" + Radio_1_5Ghz_Found);
                }
            }
            catch (Exception error)
            {
                LogMajor(error.ToString());
                throw;
            }
            finally
            {
                wlanEtwWatcher.Dispose();
            }


            LogMajor("Error locating all routers");
            if (!Radio_0_24Ghz_Found)
            {
                LogMajor("Scanning - " + Reason_Radio_0_24Ghz_Found);
                throw new Exception(Reason_Radio_0_24Ghz_Found);
            }
            if (!Radio_1_24Ghz_Found)
            {
                LogMajor("Scanning - " + Reason_Radio_1_24Ghz_Found);
                throw new Exception(Reason_Radio_1_24Ghz_Found);
            }

            if (ScanningConfiguration.DeviceSupports5Ghz)
            {
                if (!Radio_0_5Ghz_Found)
                {
                    LogMajor("Scanning - " + Reason_Radio_0_5Ghz_Found);
                    throw new Exception(Reason_Radio_0_5Ghz_Found);
                }
                if (!Radio_1_5Ghz_Found)
                {
                    LogMajor("Scanning - " + Reason_Radio_1_5Ghz_Found);
                    throw new Exception(Reason_Radio_1_5Ghz_Found);
                }
            }
        }
Exemplo n.º 3
0
        public void TestDot11wConnection()
        {
            Guid interfaceId;

            testLogger.LogComment("Testing 802.11w Connection to AP with SSID " + dot11wSSID + " and password " + dot11wPassword);
            using (Wlan wlanApi = new Wlan())
            {
                var wlanInterfaceList = wlanApi.EnumWlanInterfaces();
                Verify.IsTrue(wlanInterfaceList.Count >= 1, string.Format(CultureInfo.InvariantCulture, "wlanInterfaceList.Count = {0}", wlanInterfaceList.Count));

                var wlanInterface = wlanInterfaceList[0];
                interfaceId = wlanInterface.Id;

                // Delete Profile if present
                DisconnectAndDeleteProfile(wlanApi);

                // Scan
                testLogger.LogComment("Scan");
                wlanApi.Scan(wlanInterface.Id, false, ScanWait);

                // Check to see if SSID is in scan list
                testLogger.LogComment("Check to see if SSID is in scan list");
                var  networkList = wlanApi.GetAvailableNetworkList(interfaceId);
                bool found       = false;
                foreach (WlanNetwork network in networkList)
                {
                    if (String.Compare(network.Ssid, dot11wSSID, StringComparison.Ordinal) == 0)
                    {
                        found = true;
                        break;
                    }
                }
                if (found == false)
                {
                    testLogger.LogError("Could not find 11w router in scan list: " + dot11wSSID);
                    testLogger.LogResult(TestResult.Failed);
                    return;
                }
                else
                {
                    testLogger.LogComment("Found the 11w router in the scan list: " + dot11wSSID);
                }

                // Create Profile
                string profile = GenerateProfile();
                testLogger.LogComment("Creating Profile");
                wlanApi.CreateProfile(interfaceId, profile);

                // Connect
                testLogger.LogComment("Connecting to AP");
                wlanApi.ProfileConnect(interfaceId, dot11wSSID, new TimeSpan(0, 0, 30));
            }

            // Check MFP Status
            bool mfpStatus = IsMfpNeogotiated(interfaceId);

            testLogger.LogComment("IsMfpNeogotiated == " + mfpStatus);
            if (mfpStatus == false)
            {
                testLogger.LogError("The device connected to the dot11w router but IsMfpNeogotiated == false");
                testLogger.LogResult(TestResult.Failed);
                return;
            }

            if (enableSleepTest)
            {
                PowerManager powerManager;

                powerManager = new PowerManager();

                // Wait for DHCP Stable
                testLogger.LogComment("Wait for DHCP to be stable");
                Wlan.Sleep(1000 * 60 * 2);

                testLogger.LogComment("Going into Connected standby/Sleep for 1 minute");
                powerManager.DeepestSleep(60);

                using (Wlan wlanApi = new Wlan())
                {
                    bool isConnected = IsConnected(wlanApi);
                    if (isConnected == false)
                    {
                        testLogger.LogError("After waking from connected standby the device is no longer connected to the AP");
                    }
                    else
                    {
                        testLogger.LogComment("After waking from connected standby the device is still connected to the AP");
                    }
                }

                // Check MFP Status
                mfpStatus = IsMfpNeogotiated(interfaceId);
                testLogger.LogComment("IsMfpNeogotiated == " + mfpStatus);
                if (mfpStatus == false)
                {
                    testLogger.LogError("The device connected to the dot11w router but IsMfpNeogotiated == false");
                    return;
                }
            }
        }