Sandertv / go-raknet

Go library implementing a basic version of the RakNet protocol.
MIT License
105 stars 38 forks source link

Packets are sometimes unnecessarily resent in a loop #4

Closed gioiann closed 5 years ago

gioiann commented 5 years ago

Currently a packet is resent if no ACK is received before Round-Trip Time + 10ms since it was sent. This is "fine" for most of the servers sending ACKs every 10ms (PocketMine) But there are some servers, like SteadFast2 which instead will send ACKs every 25ms

The RTT is not perfect, changes continuously overtime and only indicates a rough estimate of the ping latency which is different than the ACK one

So, on some servers packets will be resent forever since it's impossible to receive an ACK in time.

The effect of this is not noticeable because the client and server will automatically discard duplicate packets.

gioiann commented 5 years ago

Also, on lbsg (Steadfast2 servers) the connected pong is wrongly encoded so this raknet is not able to measure the RTT at all resulting in a fixed delay of 30ms. So if an ACK isn't received in 30ms the packets will be resent. So since Steadfast2 sends ACKs every 25ms , in this case an ACK needs to arrive at a fixed 5ms delay which will never happen.

Sandertv commented 5 years ago

Fixed by 6c06f8336a136b3235f95c929edf683489d797db, thanks for the additional information on Steadfast, that was helpful.