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

UpdateSendWindow() private method

Update Send Window, remove acknowledged packet from outPacketDic
private UpdateSendWindow ( ) : void
return void
        private void UpdateSendWindow()
        {
            while (outPacketDic.ContainsKey(SendWindowStartPosition) && (outPacketDic[SendWindowStartPosition].Acknowledged))
            {
                outPacketDic.Remove(SendWindowStartPosition); // Client has receive the packet, Remove it from outPacketDic.
                SendWindowStartPosition++;
            }

            // For lossy connection, Lossy connection mark a packet as lost if received 3 ack of packets after it, so should check states from SendWindowStartPosition to CurSnSource
            if (TransMode == TransportMode.Lossy &&
                IsInSendWindow(CurSnSource)) // If all sent sources have been Acknowledged, CurSnSource should not in send window
            {
                int count = this.SocketConfig.MarkLostPacketsNumber;
                uint curPos = CurSnSource;
                while(count > 0 && IsInSendWindow(curPos))
                {
                    if (outPacketDic.ContainsKey(curPos) && (outPacketDic[curPos].Acknowledged))
                    {
                        count--;
                    }
                    curPos--;
                }
                if (IsInSendWindow(curPos))
                {
                    while (outPacketDic.ContainsKey(curPos) && (outPacketDic[curPos].Acknowledged))
                    {
                        curPos++;
                    }
                    while (SendWindowStartPosition != curPos)
                    {
                        if(outPacketDic.ContainsKey(SendWindowStartPosition) && (outPacketDic[SendWindowStartPosition].Acknowledged))
                        {
                            outPacketDic.Remove(SendWindowStartPosition);
                        }
                        SendWindowStartPosition++;
                    }
                }
            }
        }