Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpeudp.RdpeudpSocket.AckPacketReceived C# (CSharp) Method

AckPacketReceived() private method

Send Ack packet if necessary.
private AckPacketReceived ( ) : void
return void
        private void AckPacketReceived()
        {
            if (!Connected || !AutoHandle)
            {
                return;
            }

            if (this.sourceNumNotAcked >= this.SocketConfig.AckSourcePacketsNumber)
            {
                this.SendAcKPacket();
            }

            TimeSpan delayAckDuration = SocketConfig.DelayAckDuration_V1;
            if(HighestVersion == uUdpVer_Values.RDPUDP_PROTOCOL_VERSION_2)
            {
                TimeSpan half = new TimeSpan(RTT.Ticks / 2);
                // RDPUDP_PROTOCOL_VERSION_2: the delayed ACK time-out is 50 ms or half the RTT, whichever is longer, up to a maximum of 200 ms.
                delayAckDuration = SocketConfig.DelayAckDuration_V2 > half ? SocketConfig.DelayAckDuration_V2 : half;
                delayAckDuration = delayAckDuration > SocketConfig.DelayAckDuration_Max ? SocketConfig.DelayAckDuration_Max : delayAckDuration;
            }

            if (this.sourceNumNotAcked > 0 &&
                ReceiveTimeForFirstNotACKSource + delayAckDuration <= DateTime.Now)
            {
                // Send ACK diagram, and set RDPUDP_FLAG_ACKDELAYED flag
                this.SendAcKPacket(true);
            }
        }