/// <summary> /// Verify TS_FRAME_ACKNOWLEDGE_PDU /// </summary> /// <param name="ackPdu">The TS_FRAME_ACKNOWLEDGE_PDU to be verified</param> private void VerifyTS_FRAME_ACKNOWLEDGE_PDU(TS_FRAME_ACKNOWLEDGE_PDU ackPdu) { this.Site.Log.Add(LogEntryKind.Comment, "The frameID of TS_FRAME_ACKNOWLEDGE_PDU is {0}", ackPdu.frameID); if (ackPdu.frameID == 0xFFFFFFFF) { this.Site.Assert.IsTrue(ackPdu.frameID == 0xFFFFFFFF, "[TS_FRAME_ACKNOWLEDGE_PDU] If frameID has the value 0xFFFFFFFF, the server SHOULD assume that all in-flight frames have been acknowledged."); } else { this.Site.Assert.AreEqual <uint>(this.frameMakerFrameId, ackPdu.frameID, "[TS_FRAME_ACKNOWLEDGE_PDU][frameID] This field specifies the 32-bit identifier of the frame that was sent to the client using a Frame Marker Command and is being acknowledged as delivered"); } }
/// <summary> /// This method expect a TS_FRAME_ACKNOWLEDGE_PDU from client. /// </summary> /// <param name="expectedFrameId">The expected frame id.</param> /// <param name="ackTimeout">The time span to wait.</param> public void ExpectTsFrameAcknowledgePdu(uint expectedFrameId, TimeSpan ackTimeout) { this.frameMakerFrameId = expectedFrameId; if (this.rdpbcgrAdapter != null) { this.rdpbcgrAdapter.WaitForPacket <TS_FRAME_ACKNOWLEDGE_PDU>(ackTimeout); } else if (this.rdpbcgrServerStack != null && this.rdpbcgrSessionContext != null) { StackPacket receivedPdu = null; TS_FRAME_ACKNOWLEDGE_PDU ackPdu = null; bool isReceived = false; TimeSpan leftTime = ackTimeout; DateTime expiratedTime = DateTime.Now + ackTimeout; foreach (StackPacket pdu in pduCache) { ackPdu = pdu as TS_FRAME_ACKNOWLEDGE_PDU; if (ackPdu != null) { isReceived = true; pduCache.Remove(pdu); break; } } while (!isReceived && leftTime.CompareTo(new TimeSpan(0)) > 0) { try { receivedPdu = this.rdpbcgrServerStack.ExpectPdu(this.rdpbcgrSessionContext, leftTime); ackPdu = receivedPdu as TS_FRAME_ACKNOWLEDGE_PDU; if (ackPdu != null) { isReceived = true; break; } else { Site.Log.Add(LogEntryKind.TestInProgress, "Received and cached Pdu: {0}.", receivedPdu.GetType()); pduCache.Add(receivedPdu); } } catch (TimeoutException) { Site.Assert.Fail("Timeout when expecting {0}", typeof(TS_FRAME_ACKNOWLEDGE_PDU)); } catch (InvalidOperationException ex) { //break; Site.Log.Add(LogEntryKind.Warning, "Exception thrown out when receiving client PDUs {0}.", ex.Message); } finally { System.Threading.Thread.Sleep(100);//Wait some time for next packet. leftTime = expiratedTime - DateTime.Now; } } if (isReceived) { this.VerifyTS_FRAME_ACKNOWLEDGE_PDU(ackPdu); } else { site.Assert.Fail("Timeout when expecting {0}.", typeof(TS_FRAME_ACKNOWLEDGE_PDU)); } } }