Example #1
0
        public WhckAssociation(RunTimeConfiguration RuntimeConfig,
                               APConfigParameter AP1Config24GHz,
                               APConfigParameter AP1Config5GHz,
                               APConfigParameter AP2Config24GHz,
                               APConfigParameter AP2Config5GHz,
                               ASSOC_TEST_OPTIONS AssocTestOptions)
        {
            if (RuntimeConfig == null)
            {
                throw new ArgumentNullException("RuntimeConfig");
            }
            m_TraceProvider = new WlanHckTestLogger("WhckAssociation");

            this.m_AssociationConfiguration = RuntimeConfig;
            this.m_AP1Config24GHz           = AP1Config24GHz;
            this.m_AP1Config5GHz            = AP1Config5GHz;
            this.m_AP2Config24GHz           = AP2Config24GHz;
            this.m_AP2Config5GHz            = AP2Config5GHz;
            this.m_AssocTestOptions         = AssocTestOptions;

            m_WlanApi = new Wlan();

            m_TestInterface = Helpers.GetWlanInterface(m_WlanApi);

            m_ApConfigClient = Helpers.ConnectToService(m_AssociationConfiguration.ServiceBackChannelAddress);

            m_Routers = Helpers.GetRouterCollection(m_ApConfigClient);
            this.m_DeviceSupports5GHz = RuntimeConfig.DeviceSupports5Ghz;
            m_PowerManager            = new PowerManager();
            m_bIsAccessPointSetup     = false;
        }
Example #2
0
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.m_bDisposed)
            {
                if (disposing)
                {
                    if (null != m_WlanApi)
                    {
                        m_WlanApi.Dispose();
                        m_WlanApi = null;
                    }
                    if (null != m_ApConfigClient)
                    {
                        //m_ApConfigClient.StopRadiusServer();
                        m_ApConfigClient.StopEchoServer(); // Service checks if echo server was running or not
                        m_ApConfigClient.Dispose();
                        m_ApConfigClient = null;
                    }
                    // TODO Dispose here
                }
            }

            m_bDisposed = true;
        }
        public WhckRoaming(RunTimeConfiguration rc,
                           APConfigParameter AP1Config24GHz,
                           APConfigParameter AP1Config5GHz,
                           APConfigParameter AP2Config24GHz,
                           APConfigParameter AP2Config5GHz,
                           ROAM_TEST_OPTIONS RoamTestOptions)
        {
            if (rc == null)
            {
                throw new ArgumentNullException("rc");
            }
            traceProvider = new WlanHckTestLogger("WhckRoaming");

            this.RoamingConfiguration = rc;
            this.m_AP1Config24GHz     = AP1Config24GHz;
            this.m_AP1Config5GHz      = AP1Config5GHz;
            this.m_AP2Config24GHz     = AP2Config24GHz;
            this.m_AP2Config5GHz      = AP2Config5GHz;
            this.m_RoamTestOptions    = RoamTestOptions;

            Api = new Wlan();

            TestInterface = Helpers.GetWlanInterface(Api);
            AC            = Helpers.ConnectToService(RoamingConfiguration.ServiceBackChannelAddress);

            routers            = Helpers.GetRouterCollection(AC);
            AccessPointSetup   = false;
            DeviceSupports5Ghz = rc.DeviceSupports5Ghz;
        }
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                if (disposing)
                {
                    Log("WhckRoaming : Cleaning up");
                    DeleteProfiles();

                    if (echoClient != null)
                    {
                        Log("WhckRoaming : Cleaning up Echo Client");
                        echoClient.Close();
                        echoClient = null;
                    }
                    if (null != Api)
                    {
                        Api.Dispose();
                        Api = null;
                    }
                    if (null != AC)
                    {
                        if (routers != null && routers.Count == 2)
                        {
                            Log("WhckRoaming: Cleaning up static route from AP server to router");
                            AC.ClearStaticRoute(routers[0]);
                        }

                        Log("WhckRoaming : Cleaning up stopping radius server");
                        AC.StopRadiusServer();
                        Log("WhckRoaming : Cleaning up stopping Echo server");
                        AC.StopEchoServer(); // Service checks if echo server was running or not
                        AC.Dispose();
                        AC = null;
                    }

                    // TODO Dispose here
                }
            }

            disposed = true;
        }
Example #5
0
        public WhckScanning(RunTimeConfiguration rc,
                            APConfigParameter AP1Config24GHz,
                            APConfigParameter AP1Config5GHz,
                            APConfigParameter AP2Config24GHz,
                            APConfigParameter AP2Config5GHz,
                            SCAN_TEST_OPTIONS ScanTestOptions)
        {
            if (rc == null)
            {
                throw new ArgumentNullException("rc");
            }
            traceProvider = new TraceProvider("WhckScanning");
            this.ScanningConfiguration = rc;
            this.m_AP1Config24GHz      = AP1Config24GHz;
            this.m_AP1Config5GHz       = AP1Config5GHz;
            this.m_AP2Config24GHz      = AP2Config24GHz;
            this.m_AP2Config5GHz       = AP2Config5GHz;
            this.m_ScanTestOptions     = ScanTestOptions;

            Api = new Wlan();


            TestInterface = Helpers.GetWlanInterface(Api);
            AC            = null;
            AC            = Helpers.ConnectToService(ScanningConfiguration.ServiceBackChannelAddress);


            if (AC == null)
            {
                Log("Helpers.ConnectToService failed");
                AC = null;
                throw new Exception("Helpers.ConnectToService failed");
            }

            routers = Helpers.GetRouterCollection(AC);

            AccessPointSetup = false;
        }
Example #6
0
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                if (disposing)
                {
                    if (null != Api)
                    {
                        Api.Dispose();
                        Api = null;
                    }
                    if (null != AC)
                    {
                        //AC.StopEchoServer(); // Service checks if echo server was running or not
                        AC.Dispose();
                        AC = null;
                    }
                    // TODO Dispose here
                }
            }

            disposed = true;
        }
Example #7
0
        public static void ClassSetup(TestContext context)
        {
            APServer = null;

            if (context.Properties.Contains("DeviceSupports5Ghz"))
            {
                DeviceSupports5Ghz = bool.Parse(context.Properties["DeviceSupports5Ghz"].ToString());
                testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "DeviceSupports5Ghz = {0}", DeviceSupports5Ghz));
            }

            if (context.Properties.Contains("APServer"))
            {
                APServer = context.Properties["APServer"].ToString();
                testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "APServer Name = {0}", APServer));
            }
            if (context.Properties.Contains("ServiceAPChannelAddress"))
            {
                ServiceAPChannelAddress = context.Properties["ServiceAPChannelAddress"].ToString();
                testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "ServiceAPChannelAddress = {0}", ServiceAPChannelAddress));
            }

            if (context.Properties.Contains("Duration"))
            {
                int duration;
                if (Int32.TryParse(context.Properties["Duration"].ToString(), out duration))
                {
                    TestDuration = duration;
                    testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Duration = {0} minutes", TestDuration));
                }
                else
                {
                    testLogger.LogComment("Could not parse Duration. Using default.");
                }
            }

            if (APServer == null)
            {
                testLogger.LogError("Did not get AP Server name as parameter");
                return;
            }


            testLogger.LogComment("Connecting to AP Config Server - " + APServer);
            using (ApConfigClient apConfigClient = new ApConfigClient(APServer))
            {
                bool connect = apConfigClient.Connect();
                if (connect)
                {
                    testLogger.LogComment("Connection Succeeded");
                }
                else
                {
                    testLogger.LogError("Connection failed");
                    return;
                }

                testLogger.LogComment("Enum Routers");
                routers = apConfigClient.EnumerateAccessPoints();
                if (routers == null)
                {
                    testLogger.LogError("Unable to enum routers, EnumerateAccessPoints returned null");
                    return;
                }
                if (routers.Count >= 2)
                {
                    testLogger.LogComment("Found 2 routers as expected");
                }
                else
                {
                    testLogger.LogError("Did not find both APs");
                    return;
                }
            }
        }
Example #8
0
        private void ConnectForIntegrityCheck(ApConfigClient apConfigClient, int port, int streamBytes)
        {
            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];

                if (wlanInterface.State == WLAN_INTERFACE_STATE.wlan_interface_state_connected)
                {
                    return;
                }

                if (apConfigCreated == false)
                {
                    var currentConfig1 = WlanAccessPointHelper.CreateWirelessAccessPoint(AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password", AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password");
                    var currentConfig2 = WlanAccessPointHelper.CreateWirelessAccessPoint(AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password", AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password");

                    ConfiguredSSIDs configuredSSID1 = new ConfiguredSSIDs("", "");
                    ConfiguredSSIDs configuredSSID2 = new ConfiguredSSIDs("", "");

                    if (apConfigClient.ApplyConfiguration(routers[0], currentConfig1, out configuredSSID1))
                    {
                        currentConfig1.SSID_24GHZ = configuredSSID1.TwoPoint4GhzSSID;
                        currentConfig1.SSID_5GHZ  = configuredSSID1.FiveghzSSID;
                        testLogger.LogComment("Successfully applied the Configuration to AP[0]");
                    }
                    else
                    {
                        testLogger.LogError("Unable to apply the configuration to AP [0]");
                    }

                    testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Applying AP Configuration to AP[1] {0}", currentConfig2.SSID_24GHZ));
                    if (apConfigClient.ApplyConfiguration(routers[1], currentConfig2, out configuredSSID2))
                    {
                        currentConfig2.SSID_24GHZ = configuredSSID1.TwoPoint4GhzSSID;
                        currentConfig2.SSID_5GHZ  = configuredSSID1.FiveghzSSID;
                        testLogger.LogComment("Successfully applied the Configuration to AP[2]");
                    }
                    else
                    {
                        testLogger.LogError("Unable to apply the configuration to AP[2]");
                    }

                    string profile1;
                    string profile2;

                    profile1     = currentConfig1.CreateProfile24ghz(ConnectionMode.Manual, false);
                    profileName1 = currentConfig1.SSID_24GHZ;

                    profile2     = currentConfig2.CreateProfile24ghz(ConnectionMode.Manual, false);
                    profileName2 = currentConfig2.SSID_24GHZ;

                    testLogger.LogComment(profile1);

                    wlanApi.CreateProfile(wlanInterface.Id, profile1);
                    wlanApi.CreateProfile(wlanInterface.Id, profile2);

                    testLogger.LogComment("Wait to allow APs to beacon");
                    Wlan.Sleep(10000);

                    apConfigCreated = true;
                }

                int retries = 3;

                while (retries > 0)
                {
                    retries--;

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

                    try
                    {
                        testLogger.LogComment(String.Format(CultureInfo.InvariantCulture, "Attempt to Connect to SSID : {0}", profileName1));
                        wlanApi.ProfileConnect(wlanInterface.Id, profileName1, ConnectWait);
                        break;
                    }
                    catch (Exception)
                    {
                        testLogger.LogComment("Connect failed.");
                        if (retries == 0)
                        {
                            testLogger.LogError(String.Format(CultureInfo.InvariantCulture, "Could not connect to SSID: {0}", profileName1));
                            return;
                        }
                    }
                }

                testLogger.LogComment("Wait for DHCP");
                Microsoft.Test.Networking.Kit.Helpers.WaitForWlanConnectivity(wlanInterface.Id, 1000 * 15, testLogger);
            }
        }
Example #9
0
        private bool RunIntegrityCheck()
        {
            testLogger.LogComment("Running integrity check");

            UInt16 port        = 7777;
            UInt16 streamBytes = Convert.ToUInt16(random.Next(10, 2000));

            nextIntegrityCheckTime = DateTime.Now.Add(integrityCheckInterval);
            using (ApConfigClient apConfigClient = new ApConfigClient(WlanStress.APServer))
            {
                testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "WlanStress.APServer: {0}", WlanStress.APServer));
                int  retries   = 3;
                bool connected = false;
                while (retries > 0)
                {
                    retries--;
                    testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Attempting to connect to AP machine.  Retries remaining: {0}", retries));
                    bool connect = apConfigClient.Connect();
                    if (connect)
                    {
                        testLogger.LogComment("Connection to AP Server Succeeded");
                        connected = true;
                        break;
                    }
                    else
                    {
                        testLogger.LogComment("Connection AP Server failed");
                        Wlan.Sleep(10000);
                    }
                }
                if (connected == false)
                {
                    testLogger.LogError("Giving up connecting to AP machine");
                    return(false);
                }

                apConfigClient.StartEchoServer(port, streamBytes, 1);

                ConnectForIntegrityCheck(apConfigClient, port, streamBytes);

                try
                {
                    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];

                        using (Win32Sockets win32Sockets = new Win32Sockets())
                        {
                            string localAddress = win32Sockets.FindIpAddress(wlanInterface.Id);
                            testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "IPAddress: {0}", localAddress));

                            using (TCPEchoClient echoClient = new TCPEchoClient(localAddress, ServiceAPChannelAddress, port, streamBytes))
                            {
                                echoClient.Connect();
                                echoClient.PerformEcho();
                                bool result = echoClient.IsResponseBufferValid();
                                testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Echo Client Success: {0}", result));
                                return(result);
                            }
                        }
                    }
                }
                catch (Exception error)
                {
                    testLogger.LogComment("TlukeTest:  Exception hit");
                    testLogger.LogError(string.Format(CultureInfo.InvariantCulture, "Error While trying data path: {0}", error.ToString()));
                    return(false);
                }
                finally
                {
                    testLogger.LogComment("Cleaning Up Each Server");
                    apConfigClient.StopEchoServer();

                    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];

                        if (wlanInterface.State == WLAN_INTERFACE_STATE.wlan_interface_state_connected)
                        {
                            wlanApi.Disconnect(wlanInterface.Id, DisconnectWait);
                        }
                    }
                }
            }
        }