mas-bandwidth/netcode

No wraparound logic on replay protection sequence number comparisons

Closed this issue · 2 comments

Shouldn't these both have wraparound protection, similar to reliable_sequence_greater_than? Or is the value that's stored in this u64 actually a smaller integer that has somehow already accounted for this?

netcode/netcode.c

Line 1494 in 3ffe69a

if ( sequence + NETCODE_REPLAY_PROTECTION_BUFFER_SIZE <= replay_protection->most_recent_sequence )

netcode/netcode.c

Line 1512 in 3ffe69a

if ( sequence > replay_protection->most_recent_sequence )

This probably doesn't matter if the sequence numbers always start at zero and don't skip any numbers, since sending a packet every millisecond would take ~584 million years to overflow a u64.

Even at a peak packet send rate of what the internet claims is "10-Gb/s Ethernet interface: Can deliver up to 14,880,960 packets per second", it will still take 39,000 years to overflow.

It seems to be the case that it starts at zero and is incremented once per packet, so if so, feel free to close this issue.

Yes, as you calculated, the intention with 64bit sequence numbers here is that for all practical purposes, they will never overflow. Closing.