Exemple #1
0
 public void Reset()
 {
     m_sequence = 0;
     m_numAcks  = 0;
     m_sentPackets.Reset();
     m_receivedPackets.Reset();
 }
Exemple #2
0
    static void test_sequence_buffer()
    {
        Debug.Log("test_sequence_buffer");

        const int Size = 256;

        var sequenceBuffer = new Network.SequenceBuffer <TestPacketData>(Size);

        for (int i = 0; i < Size; ++i)
        {
            TestPacketData entry;
            entry.sequence = 0;
            Assert.IsTrue(sequenceBuffer.Exists((ushort)i) == false);
            Assert.IsTrue(sequenceBuffer.Available((ushort)i) == true);
            Assert.IsTrue(sequenceBuffer.Find((ushort)i) == -1);
        }

        for (int i = 0; i <= Size * 4; ++i)
        {
            int index = sequenceBuffer.Insert((ushort)i);
            Assert.IsTrue(index != -1);
            Assert.IsTrue(sequenceBuffer.GetSequence() == i + 1);
            sequenceBuffer.Entries[index].sequence = (ushort)i;
        }

        for (int i = 0; i <= Size; ++i)
        {
            // note: outside bounds!
            int index = sequenceBuffer.Insert((ushort)i);
            Assert.IsTrue(index == -1);
        }

        ushort sequence = Size * 4;

        for (int i = 0; i < Size; ++i)
        {
            int index = sequenceBuffer.Find(sequence);
            Assert.IsTrue(index >= 0);
            Assert.IsTrue(index < Size);
            Assert.IsTrue(sequenceBuffer.Entries[index].sequence == sequence);
            sequence--;
        }

        sequenceBuffer.Reset();

        Assert.IsTrue(sequenceBuffer.GetSequence() == 0);

        for (int i = 0; i < Size; ++i)
        {
            Assert.IsTrue(sequenceBuffer.Exists((ushort)i) == false);
            Assert.IsTrue(sequenceBuffer.Available((ushort)i) == true);
            Assert.IsTrue(sequenceBuffer.Find((ushort)i) == -1);
        }
    }
Exemple #3
0
    public void Reset()
    {
        Profiler.BeginSample("DeltaBuffer.Reset");

        sequenceBuffer.Reset();

        for (int i = 0; i < sequenceBuffer.GetSize(); ++i)
        {
            sequenceBuffer.Entries[i].resetSequence = 0;
            sequenceBuffer.Entries[i].numCubes      = 0;
        }

        Profiler.EndSample();
    }
Exemple #4
0
    static void test_generate_ack_bits()
    {
        Debug.Log("test_generate_ack_bits");

        const int Size = 256;

        var receivedPackets = new Network.SequenceBuffer <TestPacketData>(Size);

        ushort ack      = 0xFFFF;
        uint   ack_bits = 0xFFFFFFFF;

        Network.Util.GenerateAckBits(receivedPackets, out ack, out ack_bits);
        Assert.IsTrue(ack == 0xFFFF);
        Assert.IsTrue(ack_bits == 0);

        for (int i = 0; i <= Size; ++i)
        {
            receivedPackets.Insert((ushort)i);
        }

        Network.Util.GenerateAckBits(receivedPackets, out ack, out ack_bits);
        Assert.IsTrue(ack == Size);
        Assert.IsTrue(ack_bits == 0xFFFFFFFF);

        receivedPackets.Reset();

        ushort[] input_acks = { 1, 5, 9, 11 };
        for (int i = 0; i < input_acks.Length; ++i)
        {
            receivedPackets.Insert(input_acks[i]);
        }

        Network.Util.GenerateAckBits(receivedPackets, out ack, out ack_bits);

        Assert.IsTrue(ack == 11);
        Assert.IsTrue(ack_bits == (1 | (1 << (11 - 9)) | (1 << (11 - 5)) | (1 << (11 - 1))));
    }