public void PerformEcho()
        {
            Log("PerformEcho - Sending Echo message");
            try
            {
                echoClient.PerformEcho();

                // Validate the data (if we didnt fail in the send)
                if (!echoClient.IsResponseBufferValid())
                {
                    LogError("TestConnection: Echod Data did not match what was send");
                }
            }
            catch (Exception e)
            {
                LogError("Exchanging data over the established connection FAILED with the tcp server on AP Controller. Please check logs " + e.Message);
                //something happened kill the echo client and server and restart the server
                CloseEchoClient();
                ConnectToEchoServer();
            }
        }
Beispiel #2
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);
                        }
                    }
                }
            }
        }