Skip to content

Commit

Permalink
tweak#: Do not increment packet loss for unacknowledged packets
Browse files Browse the repository at this point in the history
Packets can arrive out of order or not be sent at all (due to recent changes and "packet stuffing") and this results in false packet loss increase with the recent changes.

It could also result in the packets being "double counted" for packet loss, due to another packet increment being when the packet wait time expires
  • Loading branch information
Frooxius committed Jun 26, 2024
1 parent 00af008 commit 8fa5228
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions LiteNetLib/ReliableChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,17 @@ private void ProcessAck(NetPacket packet)
break;
}

ref var pendingPacket = ref _pendingPackets[pendingSeq % _maxWindowSize];

// This packet isn't sent at all, we ignore it
if (!pendingPacket.IsSent)
continue;

int pendingIdx = pendingSeq % _maxWindowSize;
int currentByte = NetConstants.ChanneledHeaderSize + pendingIdx / BitsInByte;
int currentBit = pendingIdx % BitsInByte;
if ((acksData[currentByte] & (1 << currentBit)) == 0)
{
if (Peer.NetManager.EnableStatistics)
{
Peer.Statistics.IncrementPacketLoss();
Peer.NetManager.Statistics.IncrementPacketLoss();
}

//Skip false ack
NetDebug.Write($"[PA]False ack: {pendingSeq}");
continue;
Expand Down

0 comments on commit 8fa5228

Please sign in to comment.