Exemplo n.º 1
0
            static List <byte[]> Update(ref int processed, List <byte[]> ToSend, SubIRawConnection connection, AckSystem ackSystem, float dropChance, float skipChance)
            {
                int count1 = connection.packets.Count;

                for (int i = processed; i < count1; i++)
                {
                    byte[] packet = connection.packets[i];
                    if (UnityEngine.Random.value > dropChance)
                    {
                        ToSend.Add(packet);
                    }
                }
                processed = count1;

                var newPackets = new List <byte[]>();

                for (int i = 0; i < ToSend.Count; i++)
                {
                    if (UnityEngine.Random.value < skipChance)
                    {
                        continue;
                    }
                    newPackets.AddRange(Receive(ackSystem, ToSend[i]));
                    ToSend.RemoveAt(i);
                    i--;
                }

                return(newPackets);
            }
Exemplo n.º 2
0
 public BadSocket(AckTestInstance instance1, AckTestInstance instance2)
 {
     ackSystem1  = instance1.ackSystem;
     ackSystem2  = instance2.ackSystem;
     connection1 = instance1.connection;
     connection2 = instance2.connection;
 }
        public void SetUp()
        {
            var config = new Config();

            maxSequence = (ushort)((1 << config.SequenceSize) - 1);

            connection = new SubIRawConnection();
            ackSystem  = new AckSystem(connection, config, new Time(), bufferPool);

            message = createRandomData(1);
            ackSystem.SendNotify(message);

            // should have got 1 packet
            Assert.That(connection.packets.Count, Is.EqualTo(1));
            packet = connection.packets[0];

            // should have sent data
            Assert.That(packet, Is.Not.Null);
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            config = new Config();
            var mtu     = MAX_PACKET_SIZE;
            var bigSize = (int)(mtu * 1.5f);

            message = CreateBigData(1, bigSize);

            var sender = new AckTestInstance();

            sender.connection = new SubIRawConnection();
            sender.ackSystem  = new AckSystem(sender.connection, config, MAX_PACKET_SIZE, new Time(), bufferPool);
            sender.ackSystem.SendReliable(message);
            packet1 = sender.packet(0);
            packet2 = sender.packet(1);


            var connection = new SubIRawConnection();

            ackSystem = new AckSystem(connection, config, MAX_PACKET_SIZE, new Time(), bufferPool);
        }
Exemplo n.º 5
0
 public void SetUp()
 {
     connection = new SubIRawConnection();
     ackSystem  = new AckSystem(connection, default, new Time());