Exemplo n.º 1
0
        public void TestAck2()
        {
            SocketMessage package1 = new SocketMessage(Config.Default.PackageSize);

            package1.SetSeq(0);
            SocketMessage package2 = new SocketMessage(Config.Default.PackageSize);

            package2.SetSeq(1);
            SocketMessage package3 = new SocketMessage(Config.Default.PackageSize);

            package3.SetSeq(2);

            CongestionRecorder ackWaiter = new CongestionRecorder(3);
            PackageRectifier   rectifier = new PackageRectifier();

            ackWaiter.PushWait(package1, 1);
            ackWaiter.PushWait(package2, 2);
            ackWaiter.PushWait(package3, 3);

            rectifier.PushPackage(package3);
            rectifier.PushPackage(package1);


            ackWaiter.ReplyBefore((ushort)(rectifier.Serial - 1), 1, 1);
            ackWaiter.ReplyAfter((ushort)(rectifier.Serial - 1), rectifier.SerialBitFields, 1, 1);

            Assert.Equal(1, ackWaiter.Count);

            List <SocketMessage> outs = ackWaiter.PopLost(Timestamp.OneSecondTicks * 60, Timestamp.OneSecondTicks * 60);

            Assert.Equal(1, outs[0].GetSeq());
        }
Exemplo n.º 2
0
        public void TestAck1()
        {
            SocketMessage package1 = new SocketMessage(Config.Default.PackageSize);

            package1.SetSeq(1);
            SocketMessage package2 = new SocketMessage(Config.Default.PackageSize);

            package2.SetSeq(2);

            CongestionRecorder ackWaiter = new CongestionRecorder(3);


            ackWaiter.PushWait(package1, (long)(Timestamp.OneSecondTicks * 0.1));
            ackWaiter.PushWait(package2, Timestamp.OneSecondTicks);
            ackWaiter.Reply(package1.GetSeq(), Timestamp.OneSecondTicks, 1);
            List <SocketMessage> packages = ackWaiter.PopLost(Timestamp.OneSecondTicks * 100, Timestamp.OneSecondTicks * 100);

            Assert.Equal(2u, packages[0].GetSeq());
        }