Class PacketNumberFilter
java.lang.Object
io.github.mahmoudimus.quic.connection.PacketNumberFilter
Mitigates optimistic ACK attacks (RFC 9000 section 21.4) by occasionally skipping a packet
number in the application data space: an ACK of a skipped number proves the peer acknowledges
packets it never received. Skips get exponentially rarer, since a peer that behaved for long is
less likely to start misbehaving.
Threads. Not thread-safe; owned by one connection.
-
Constructor Summary
ConstructorsConstructorDescriptionPacketNumberFilter(RandomGenerator random) A filter whose first skip is somewhere in packet numbers 0 to 63. -
Method Summary
Modifier and TypeMethodDescriptionlongallocate(RandomGenerator random, PacketSpace space) Allocates the next packet number, skipping it if it is the chosen one.voidRejects an ACK of the skipped packet number.static PacketNumberFilterdisabled()A filter that never skips, for tests.longpeek(PacketSpace space) The packet numberallocate(java.util.random.RandomGenerator, io.github.mahmoudimus.quic.connection.PacketSpace)would return next.
-
Constructor Details
-
PacketNumberFilter
A filter whose first skip is somewhere in packet numbers 0 to 63.- Parameters:
random- the source of randomness
-
-
Method Details
-
disabled
A filter that never skips, for tests.- Returns:
- the filter
-
peek
The packet numberallocate(java.util.random.RandomGenerator, io.github.mahmoudimus.quic.connection.PacketSpace)would return next.- Parameters:
space- the application data space- Returns:
- the packet number
-
allocate
Allocates the next packet number, skipping it if it is the chosen one.- Parameters:
random- the source of randomnessspace- the application data space- Returns:
- the packet number to send
-
checkAck
Rejects an ACK of the skipped packet number.- Parameters:
space- the space the ACK arrived insmallest- the smallest packet number of an acknowledged rangelargest- the largest packet number of the range- Throws:
QuicException-PROTOCOL_VIOLATIONif the range covers a skipped packet number
-