コード例 #1
0
        public void S2_DataTransfer_SecurityChannelCreation_ReliableConnection()
        {
            CheckSecurityProtocolForMultitransport();

            Site.Log.Add(LogEntryKind.Debug, "Establishing RDP connection ...");
            StartRDPConnection();

            this.TestSite.Log.Add(LogEntryKind.Comment, "Create a reliable UDP connection.");
            this.EstablishUDPConnection(TransportMode.Reliable, waitTime, true, true);

            // Set the autoHandle to true, then can be used for create security channel.
            this.TestSite.Log.Add(LogEntryKind.Comment, "Start TLS handshake.");

            String certFile;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePath", out certFile);

            String certPwd;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePassword", out certPwd);

            X509Certificate2 cert = new X509Certificate2(certFile, certPwd);

            rdpemtServerR = new RdpemtServer(rdpeudpSocketR, cert, false);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Wait for a RDP_TUNNEL_CREATEREQUEST message from client after security channel creation");
            RDP_TUNNEL_CREATEREQUEST createReq = rdpemtServerR.ExpectTunnelCreateRequest(waitTime);

            Site.Assert.IsNotNull(createReq, "Client should send a RDP_TUNNEL_CREATEREQUEST message after security channel creation.");
        }
コード例 #2
0
        public void S1_Connection_Initialization_NegativeTest_InitialLossyConnection_RDPEncryption()
        {
            CheckPlatformCompatibility(TransportMode.Lossy);

            Site.Log.Add(LogEntryKind.Debug, "Establishing RDP connection, used RDP encryption");
            StartRDPConnection(true);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Create a {0} UDP connection.", TransportMode.Lossy);
            this.EstablishUDPConnection(TransportMode.Lossy, waitTime);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Start DTLS handshake.");
            String certFile;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePath", out certFile);

            String certPwd;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePassword", out certPwd);

            X509Certificate2 cert = new X509Certificate2(certFile, certPwd);

            RdpeudpDTLSChannel sChannel = new RdpeudpDTLSChannel(rdpeudpSocketL);

            sChannel.AuthenticateAsServer(cert);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Expect for Client Initiate Multitransport Error PDU to indicate Client drop RDP-UDP connection");
            this.rdpbcgrAdapter.WaitForPacket <Client_Initiate_Multitransport_Response_PDU>(waitTime);

            if (requestIdList.Count == 1)
            {
                VerifyClientInitiateMultitransportResponsePDU(rdpbcgrAdapter.SessionContext.ClientInitiateMultitransportResponsePDU, requestIdList[0]);
            }
        }
コード例 #3
0
        /// <summary>
        /// Verify the version of operation system or MSTSC
        /// </summary>
        private void VerifyRDPVersion()
        {
            string RDPClientVersion;

            PtfPropUtility.GetPtfPropertyValue(Site, "Version", out RDPClientVersion);

            this.Site.Assert.AreEqual <String>(RDPClientVersion, "8.1", "MS-RDPEDISP only support RDP 8.1 and above.");
        }
コード例 #4
0
        /// <summary>
        /// Get the First valid UDP Source Packet.
        /// </summary>
        /// <param name="udpTransportMode"></param>
        /// <returns></returns>
        private RdpeudpPacket GetFirstValidUdpPacket(TransportMode udpTransportMode)
        {
            byte[]        dataToSent  = null;
            RdpeudpPacket firstPacket = null;
            String        certFile;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePath", out certFile);

            String certPwd;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePassword", out certPwd);

            X509Certificate2 cert = new X509Certificate2(certFile, certPwd);

            if (udpTransportMode == TransportMode.Reliable)
            {
                RdpeudpTLSChannel secChannel = new RdpeudpTLSChannel(rdpeudpSocketR);
                secChannel.AuthenticateAsServer(cert);
                RdpeudpPacket packet = rdpeudpSocketR.ExpectPacket(waitTime);
                if (packet.payload != null)
                {
                    rdpeudpSocketR.ProcessSourceData(packet); // Process Source Data to make sure ACK Vector created next is correct
                    secChannel.ReceiveBytes(packet.payload);
                }
                dataToSent = secChannel.GetDataToSent(waitTime);

                // Make sure this test packet does not exceed upstream MTU.
                int maxPayloadsize = GetMaxiumPayloadSizeForSourcePacket(rdpeudpSocketR.UUpStreamMtu);

                dataToSent = dataToSent.Take(maxPayloadsize).ToArray();

                firstPacket = rdpeudpSocketR.CreateSourcePacket(dataToSent);
            }
            else
            {
                RdpeudpDTLSChannel secChannel = new RdpeudpDTLSChannel(rdpeudpSocketL);
                secChannel.AuthenticateAsServer(cert);
                RdpeudpPacket packet = rdpeudpSocketL.ExpectPacket(waitTime);
                if (packet.payload != null)
                {
                    rdpeudpSocketL.ProcessSourceData(packet); // Process Source Data to make sure ACK Vector created next is correct
                    secChannel.ReceiveBytes(packet.payload);
                }
                dataToSent = secChannel.GetDataToSent(waitTime);

                // Make sure this test packet does not exceed upstream MTU.
                int maxPayloadsize = GetMaxiumPayloadSizeForSourcePacket(rdpeudpSocketL.UUpStreamMtu);

                dataToSent = dataToSent.Take(maxPayloadsize).ToArray();

                firstPacket = rdpeudpSocketL.CreateSourcePacket(dataToSent);
            }

            return(firstPacket);
        }
コード例 #5
0
 //private get Test Data
 private void GetTestData()
 {
     testData = new RdpevorTestData();
     try
     {
         String RdpevorTestDataPath;
         PtfPropUtility.GetPtfPropertyValue(Site, "RdpevorTestDataPath", out RdpevorTestDataPath);
         testData.LoadXMLFile(RdpevorTestDataPath);
     }
     catch (System.Xml.XmlException ex)
     {
         this.TestSite.Assert.Fail(ex.Message);
     }
 }
コード例 #6
0
        /// <summary>
        /// Get Test Data file path
        /// </summary>
        /// <param name="callStackIndex"></param>
        /// <returns></returns>
        private string GetTestDataFile(int callStackIndex = 1)
        {
            StackTrace st           = new StackTrace();
            StackFrame sf           = st.GetFrame(callStackIndex);
            string     testCaseName = sf.GetMethod().Name;

            String h264TestDataPath;

            if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RdpegfxH264TestDataPath", out h264TestDataPath))
            {
                Site.Assert.Fail("Cannot get its test data path");
            }

            return(h264TestDataPath + @"\" + testCaseName + ".xml");
        }
コード例 #7
0
        /// <summary>
        /// Get Test Data file path
        /// </summary>
        /// <param name="callStackIndex"></param>
        /// <returns></returns>
        private string GetTestDataFile(int callStackIndex = 1)
        {
            StackTrace st           = new StackTrace();
            StackFrame sf           = st.GetFrame(callStackIndex);
            string     testCaseName = sf.GetMethod().Name;

            String h264TestDataPath;

            if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "RdpegfxH264TestDataPath", out h264TestDataPath))
            {
                Site.Assert.Fail("Cannot get its test data path");
            }

            string testDataFilePath = Path.Combine(h264TestDataPath, $"{testCaseName}.xml");

            return(testDataFilePath);
        }
        public void RDPEGFX_CacheManagement_PositiveTest_SurfaceToCache_MaxCacheSlot()
        {
            ushort maxCacheSlot = RdpegfxTestUtility.maxCacheSlot;

            string RDPClientVersion;

            PtfPropUtility.GetPtfPropertyValue(Site, "Version", out RDPClientVersion);
            if (string.CompareOrdinal(RDPClientVersion, "10.3") == 0) // RDP 10.3 maxCacheSlot is 4096.
            {
                maxCacheSlot = 4096;
            }

            // Init for capability exchange
            RDPEGFX_CapabilityExchange();

            if (this.isSmallCache)
            {
                maxCacheSlot = RdpegfxTestUtility.maxCacheSlotForSmallCache;
            }

            // Create a surface
            this.TestSite.Log.Add(LogEntryKind.Comment, "Create a Surface.");
            RDPGFX_RECT16 surfRect = RdpegfxTestUtility.ConvertToRect(RdpegfxTestUtility.surfPos, RdpegfxTestUtility.surfWidth, RdpegfxTestUtility.surfHeight);
            Surface       surf     = this.rdpegfxAdapter.CreateAndOutputSurface(surfRect, PixelFormat.PIXEL_FORMAT_ARGB_8888);

            this.TestSite.Assert.IsNotNull(surf, "Surface {0} is created", surf.Id);

            List <RDPGFX_POINT16> destPointList = new List <RDPGFX_POINT16>();
            RDPGFX_POINT16        pos           = new RDPGFX_POINT16(RdpegfxTestUtility.cacheRect.right, RdpegfxTestUtility.cacheRect.bottom);

            destPointList.Add(pos);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Copy a rect to cache; and copy the cached rect to surface, using max cacheSlot: {0}.", maxCacheSlot);
            uint fid = this.rdpegfxAdapter.FillSurfaceByCachedBitmap(surf, RdpegfxTestUtility.cacheRect, RdpegfxTestUtility.cacheKey, destPointList.ToArray(), maxCacheSlot, RdpegfxTestUtility.fillColorRed);

            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface is filled by cached bitmap in frame: {0}, use max cacheSlot number {1}.", fid, maxCacheSlot);

            this.rdpegfxAdapter.ExpectFrameAck(fid);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Verify output on SUT Display if the verifySUTDisplay entry in PTF config is true.");
            this.VerifySUTDisplay(false, surfRect);

            // Delete the surface after wait 3 seconds.
            this.rdpegfxAdapter.DeleteSurface(surf.Id);
            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface {0} is deleted", surf.Id);
        }
コード例 #9
0
        public override void Initialize(ITestSite testSite)
        {
            base.Initialize(testSite);

            #region WaitTime
            string strWaitTime;
            PtfPropUtility.GetPtfPropertyValue(Site, "WaitTime", out strWaitTime);
            if (!string.IsNullOrEmpty(strWaitTime))
            {
                int waitSeconds = Int32.Parse(strWaitTime);
                waitTime = new TimeSpan(0, 0, waitSeconds);
            }
            else
            {
                waitTime = new TimeSpan(0, 0, 20);
            }
            #endregion
        }
コード例 #10
0
        /// <summary>
        /// Used to establish a RDPEMT connection
        /// </summary>
        /// <param name="udpTransportMode">Transport Mode: Reliable or Lossy</param>
        /// <param name="timeout">wait time</param>
        private void EstablishRdpemtConnection(TransportMode udpTransportMode, TimeSpan timeout, bool verifyPacket = false)
        {
            RdpeudpSocket rdpeudpSocket = rdpeudpSocketR;

            if (udpTransportMode == TransportMode.Lossy)
            {
                rdpeudpSocket = rdpeudpSocketL;
            }

            String certFile;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePath", out certFile);

            String certPwd;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePassword", out certPwd);

            X509Certificate2 cert         = new X509Certificate2(certFile, certPwd);
            RdpemtServer     rdpemtServer = new RdpemtServer(rdpeudpSocket, cert, false);

            uint receivedRequestId;

            byte[] receivedSecurityCookie;
            if (!rdpemtServer.ExpectConnect(waitTime, out receivedRequestId, out receivedSecurityCookie))
            {
                Site.Assert.Fail("RDPEMT tunnel creation failed");
            }

            if (verifyPacket)
            {
                VerifyTunnelCreateRequestPacket(receivedRequestId, receivedSecurityCookie);
            }

            if (udpTransportMode == TransportMode.Reliable)
            {
                rdpemtServerR = rdpemtServer;
            }
            else
            {
                rdpemtServerL = rdpemtServer;
            }
        }
コード例 #11
0
        /// <summary>
        /// Load Rdpedisp test image RdpedispTestImage
        /// </summary>
        /// <returns></returns>
        private Bitmap LoadImage()
        {
            // Load Rdpedisp test image
            String RdpedispTestImagePath;
            Bitmap testImage = null;

            if (!PtfPropUtility.GetPtfPropertyValue(this.TestSite, "RdpedispTestImage", out RdpedispTestImagePath))
            {
                RdpedispTestImagePath = "";
                return(null);
            }
            try
            {
                testImage = new Bitmap(RdpedispTestImagePath);
            }
            catch (System.IO.FileNotFoundException)
            {
                this.TestSite.Log.Add(LogEntryKind.TestError, "File {0} not find.", RdpedispTestImagePath);
            }
            return(testImage);
        }
        public void RDPEGFX_CacheManagement_PositiveTest_SurfaceToCache_MaxCacheSize()
        {
            int maxCacheSize = RdpegfxTestUtility.maxCacheSize;

            string RDPClientVersion;

            PtfPropUtility.GetPtfPropertyValue(Site, "Version", out RDPClientVersion);
            if (string.CompareOrdinal(RDPClientVersion, "10.3") == 0) // RDP 10.3 client maxCacheSize is 16M.
            {
                maxCacheSize = 16;
            }

            // Init for capability exchange
            RDPEGFX_CapabilityExchange();

            if (this.isSmallCache)
            {
                maxCacheSize = RdpegfxTestUtility.maxCacheSizeForSmallCache;
            }
            // Create a surface
            this.TestSite.Log.Add(LogEntryKind.Comment, "Create a Surface.");
            RDPGFX_RECT16 surfRect = RdpegfxTestUtility.ConvertToRect(RdpegfxTestUtility.surfPos, RdpegfxTestUtility.largeSurfWidth, RdpegfxTestUtility.largeSurfHeight);
            Surface       surf     = this.rdpegfxAdapter.CreateAndOutputSurface(surfRect, PixelFormat.PIXEL_FORMAT_ARGB_8888);

            this.TestSite.Assert.IsNotNull(surf, "Surface {0} is created", surf.Id);

            // Add Image to cache, 1M for each image
            this.TestSite.Log.Add(LogEntryKind.Comment, "Copy rects of surface to cache, each rect is 1M, there are {0} slot in total to reach max size.", maxCacheSize);
            for (ushort slot = 1; slot <= maxCacheSize; slot++)
            {
                this.TestSite.Log.Add(LogEntryKind.Comment, "Copy a rect of surface to cache, slot is {0}.", slot);
                uint fid = this.rdpegfxAdapter.CacheSurface(surf, RdpegfxTestUtility.largeCacheRect, RdpegfxTestUtility.cacheKey, slot, RdpegfxTestUtility.fillColorRed);
                this.rdpegfxAdapter.ExpectFrameAck(fid);
            }

            // Delete the surface after wait 3 seconds.
            this.rdpegfxAdapter.DeleteSurface(surf.Id);
            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface {0} is deleted", surf.Id);
        }
コード例 #13
0
        /// <summary>
        /// Get Test Image Data
        /// </summary>
        private void GetTestData()
        {
            testData = new RdpegfxTestUtility();

            // Load clearcodec image
            String RdpegfxClearCodecImagePath;

            if (!PtfPropUtility.GetStringPtfProperty(TestSite, "ClearCodecImage", out RdpegfxClearCodecImagePath))
            {
                RdpegfxClearCodecImagePath = "";
            }

            try
            {
                testData.ClearCodecImage = (Bitmap)Image.FromFile(RdpegfxClearCodecImagePath);
            }
            catch (System.IO.FileNotFoundException)
            {
                testData.ClearCodecImage = RdpegfxTestUtility.captureFromScreen(0, 0, RdpegfxTestUtility.surfWidth, RdpegfxTestUtility.surfHeight);
            }

            // Load RfxProgressiveCodec image
            String RdpegfxRfxProgCodecImagePath;

            if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RfxProgressiveCodecImage", out RdpegfxRfxProgCodecImagePath))
            {
                RdpegfxRfxProgCodecImagePath = "";
            }
            try
            {
                testData.RfxProgCodecImage = (Bitmap)Image.FromFile(RdpegfxRfxProgCodecImagePath);
            }
            catch (System.IO.FileNotFoundException)
            {
                testData.RfxProgCodecImage = RdpegfxTestUtility.captureFromScreen(0, 0, RdpegfxTestUtility.surfWidth, RdpegfxTestUtility.surfHeight);
            }
        }
コード例 #14
0
        protected override void TestInitialize()
        {
            base.TestInitialize();

            VerifyInteractiveRdpedispTestCase();

            try
            {
                bool isValid = PtfPropUtility.GetPtfPropertyValue(Site, "OriginalDesktopWidth", out originalDesktopWidth) &&
                               PtfPropUtility.GetPtfPropertyValue(Site, "OriginalDesktopHeight", out originalDesktopHeight) &&
                               PtfPropUtility.GetPtfPropertyValue(Site, "ChangedDesktopWidth", out changedDesktopWidth) &&
                               PtfPropUtility.GetPtfPropertyValue(Site, "ChangedDesktopHeight", out changedDesktopHeight) &&
                               PtfPropUtility.GetPtfPropertyValue(Site, "OriginalMonitorNumber", out originalMonitorNumber) &&
                               PtfPropUtility.GetPtfPropertyValue(Site, "ChangedMonitorNumber", out changedMonitorNumber);
                if (!isValid)
                {
                    throw new InvalidCastException("Invalid configured parameters");
                }
            }
            catch (Exception)
            {
                originalDesktopWidth  = 1024;
                originalDesktopHeight = 768;
                changedDesktopWidth   = 1152;
                changedDesktopHeight  = 864;
                originalMonitorNumber = 1;
                changedMonitorNumber  = 2;
            }

            this.rdpedispAdapter = this.TestSite.GetAdapter <IRdpedispAdapter>();
            this.rdpedispAdapter.Reset();
            this.rdpedispSutControlAdapter = this.TestSite.GetAdapter <IRdpedispSUTControlAdapter>();

            //Start RDP listening.
            this.TestSite.Log.Add(LogEntryKind.Comment, "Starting RDP listening with transport protocol: {0}", transportProtocol.ToString());
            this.rdpbcgrAdapter.StartRDPListening(transportProtocol);
        }
コード例 #15
0
        private void LoadConfig()
        {
            string tempStr;

            if (PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerName", out tempStr))
            {
                serverName = tempStr;
            }

            serverPort = int.Parse(Site.Properties["RDP.ServerPort"]);

            if (PtfPropUtility.GetStringPtfProperty(Site, "RDP.ClientName", out tempStr))
            {
                localAddress = tempStr;
            }

            string strWaitTime = Site.Properties["WaitTime"];

            if (strWaitTime != null)
            {
                int waitSeconds = Int32.Parse(strWaitTime);
                timeout = new TimeSpan(0, 0, waitSeconds);
            }
        }
コード例 #16
0
        public void S2_RDPEDISP_OrientationAllChange_EnhancedAdapterDemo()
        {
            #region Test Steps
            // 1. Establish the RDP connection between server and client.
            // 2. Open a Display Control dynamic virtual channel named "Microsoft::Windows::RDS::DisplayControl".
            // 3. Test suite should send a DISPLAYCONTROL_CAPS_PDU to client.
            // 4. Trigger client to change screen orientation from Landscape to Portrait and maximize the window of RDP session.
            // 5. Expect DISPLAYCONTROL_MONITOR_LAYOUT_PDU from client and verify this message.
            // 6. If the above requirements are all satisfied, test suite should send surface management commands to restart the graphics pipeline.
            // 7. Expect client to change screen orientation of the remote desktop session.
            // 8. Trigger client to change screen orientation from Landscape (flipped) to Portrait (flipped) and maximize the window of RDP session.
            // 9. Repeat Step 5 to 7.
            // 10. Trigger client to change screen orientation from Portrait (flipped) to Landscape to and maximize the window of RDP session.
            // 11. Repeat Step 5 to 7.
            #endregion

            #region Test Code
            // For Surface RT you should use the following as screen width
            // ushort screenWidth = (ushort)(originalDesktopWidth - 2);
            ushort screenWidth  = originalDesktopWidth;
            ushort screenHeight = originalDesktopHeight;

            RDPConnect(NotificationType.SurfaceManagementCommand, false);

            string pdpedispOrientationChange1Image;
            PtfPropUtility.GetPtfPropertyValue(Site, "RdpedispOrientationChange1Image", out pdpedispOrientationChange1Image);
            Bitmap instructionBitmap = new Bitmap(pdpedispOrientationChange1Image);

            SendInstruction(screenWidth, screenHeight, instructionBitmap);

            ChangeDesktopOrientation(this.TestContext.TestName, MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT, true);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Send Surface management commands");
            this.rdpegfxAdapter.ResetGraphics(originalDesktopHeight, originalDesktopWidth);

            System.Threading.Thread.Sleep(1000);

            string rdpedispOrientationChange2Image;
            PtfPropUtility.GetPtfPropertyValue(Site, "RdpedispOrientationChange2Image", out rdpedispOrientationChange2Image);
            instructionBitmap = new Bitmap(rdpedispOrientationChange2Image);
            SendInstruction(screenHeight, screenWidth, instructionBitmap);

            ChangeDesktopOrientation(this.TestContext.TestName, MonitorLayout_OrientationValues.ORIENTATION_LANDSCAPE_FLIPPED, true);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Send Surface management commands");
            this.rdpegfxAdapter.ResetGraphics(originalDesktopWidth, originalDesktopHeight);

            System.Threading.Thread.Sleep(1000);

            string rdpedispOrientationChange3Image;
            PtfPropUtility.GetPtfPropertyValue(Site, "RdpedispOrientationChange3Image", out rdpedispOrientationChange3Image);
            instructionBitmap = new Bitmap(rdpedispOrientationChange3Image);

            SendInstruction(screenWidth, screenHeight, instructionBitmap);

            ChangeDesktopOrientation(this.TestContext.TestName, MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT_FLIPPED, true);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Send Surface management commands");
            this.rdpegfxAdapter.ResetGraphics(originalDesktopHeight, originalDesktopWidth);

            // wait time to display the result and then restore the default configuration
            System.Threading.Thread.Sleep(1000);

            string rdpedispOrientationChange4Image;
            PtfPropUtility.GetPtfPropertyValue(Site, "RdpedispOrientationChange4Image", out rdpedispOrientationChange4Image);
            instructionBitmap = new Bitmap(rdpedispOrientationChange4Image);
            SendInstruction(screenHeight, screenWidth, instructionBitmap);

            ChangeDesktopOrientation(this.TestContext.TestName, MonitorLayout_OrientationValues.ORIENTATION_LANDSCAPE, true);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Send Surface management commands");
            this.rdpegfxAdapter.ResetGraphics(originalDesktopWidth, originalDesktopHeight);

            string rdpedispEndImage;
            PtfPropUtility.GetPtfPropertyValue(Site, "RdpedispEndImage", out rdpedispEndImage);
            instructionBitmap = new Bitmap(rdpedispEndImage);
            SendInstruction(screenWidth, screenHeight, instructionBitmap);

            // wait time to display the result and then restore the default configuration
            System.Threading.Thread.Sleep(1000);
            #endregion
        }
コード例 #17
0
        /// <summary>
        /// Used to establish a RDPEMT connection.
        /// </summary>
        /// <param name="udpTransportMode">Transport Mode: Reliable or Lossy.</param>
        /// <param name="timeout">Wait time.</param>
        /// <returns>true,false.</returns>
        private bool EstablishRdpemtConnection(TransportMode udpTransportMode, TimeSpan timeout)
        {
            bool pass = true;
            RdpeudpServerSocket rdpeudpSocket = rdpeudpSocketR;

            if (udpTransportMode == TransportMode.Lossy)
            {
                rdpeudpSocket = rdpeudpSocketL;
            }

            if (!rdpeudpSocket.AutoHandle)
            {
                rdpeudpSocket.AutoHandle = true;
            }

            String certFile;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePath", out certFile);

            String certPwd;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePassword", out certPwd);

            X509Certificate2 cert = new X509Certificate2(certFile, certPwd);


            RdpemtServer rdpemtServer = new RdpemtServer(rdpeudpSocket, cert);

            uint receivedRequestId;

            byte[] receivedSecurityCookie;
            if (!rdpemtServer.ExpectConnect(waitTime, out receivedRequestId, out receivedSecurityCookie))
            {
                pass = false;
            }

            rdpeudpSocket.AutoHandle = false;

            if (udpTransportMode == TransportMode.Reliable)
            {
                rdpemtServerR = rdpemtServer;
            }
            else
            {
                rdpemtServerL = rdpemtServer;
            }

            if (!pass)
            {
                this.TestSite.Log.Add(LogEntryKind.Comment, "Create a {0} RDPEMT connection failed, stop rdpeudpServer and close socket connection and retry.", udpTransportMode);
                rdpeudpServer.Stop();
                rdpeudpServer = null;
                if (udpTransportMode == TransportMode.Reliable)
                {
                    rdpeudpSocketR.Close();
                    rdpeudpSocketR = null;
                }
                else
                {
                    rdpeudpSocketL.Close();
                    rdpeudpSocketL = null;
                }
            }

            return(pass);
        }