void AckHandles(UdpHeader header, bool updateRtt)
        {
            while (!sendWindow.Empty)
            {
                UdpHandle handle = sendWindow.Peek();

                int seqDistance = UdpMath.SeqDistance(handle.ObjSequence, header.AckSequence, UdpHeader.SEQ_PADD);
                if (seqDistance > 0)
                {
                    break;
                }

                if (handle.IsObject)
                {
                    if (seqDistance <= -UdpSocket.AckRedundancy)
                    {
                        // track stats
                        stats.PacketLost();
                        socket.Statistics.PacketLost();

                        // handle lost
                        ObjectLost(handle.Object);
                    }
                    else
                    {
                        if ((header.AckHistory & (1UL << -seqDistance)) != 0UL)
                        {
                            // track stats
                            stats.PacketDelivered();
                            socket.Statistics.PacketDelivered();

                            // handle delivered objects
                            ObjectDelivered(handle.Object);
                        }
                        else
                        {
                            // track stats
                            stats.PacketLost();
                            socket.Statistics.PacketLost();

                            // handle
                            ObjectLost(handle.Object);
                        }
                    }
                }

                if (seqDistance == 0 && header.AckTime > 0)
                {
                    UpdatePing(recvTime, handle.SendTime, header.AckTime);
                }

                sendWindow.Dequeue();
            }
        }
Example #2
0
        void AckHandles(UdpHeader header, bool updateRtt)
        {
            while (!sendWindow.Empty)
            {
                UdpHandle handle = sendWindow.Peek();

                int seqDistance = UdpMath.SeqDistance(handle.ObjSequence, header.AckSequence, UdpHeader.SEQ_PADD);
                if (seqDistance > 0)
                {
                    break;
                }

                if (handle.IsObject)
                {
                    if (seqDistance <= -socket.Config.AckRedundancy)
                    {
                        ObjectLost(handle.Object);
                    }

                    if ((header.AckHistory & (1UL << -seqDistance)) != 0UL)
                    {
                        ObjectDelivered(handle.Object);
                    }
                    else
                    {
                        ObjectLost(handle.Object);
                    }
                }

                if (seqDistance == 0 && header.AckTime > 0)
                {
                    UpdatePing(recvTime, handle.SendTime, header.AckTime);
                }

                sendWindow.Dequeue();
            }
        }