Skip to content

Commit 8fa5228

Browse files
committed
tweak#: Do not increment packet loss for unacknowledged packets
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
1 parent 00af008 commit 8fa5228

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

LiteNetLib/ReliableChannel.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,17 @@ private void ProcessAck(NetPacket packet)
197197
break;
198198
}
199199

200+
ref var pendingPacket = ref _pendingPackets[pendingSeq % _maxWindowSize];
201+
202+
// This packet isn't sent at all, we ignore it
203+
if (!pendingPacket.IsSent)
204+
continue;
205+
200206
int pendingIdx = pendingSeq % _maxWindowSize;
201207
int currentByte = NetConstants.ChanneledHeaderSize + pendingIdx / BitsInByte;
202208
int currentBit = pendingIdx % BitsInByte;
203209
if ((acksData[currentByte] & (1 << currentBit)) == 0)
204210
{
205-
if (Peer.NetManager.EnableStatistics)
206-
{
207-
Peer.Statistics.IncrementPacketLoss();
208-
Peer.NetManager.Statistics.IncrementPacketLoss();
209-
}
210-
211211
//Skip false ack
212212
NetDebug.Write($"[PA]False ack: {pendingSeq}");
213213
continue;

0 commit comments

Comments
 (0)