Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect SRTT calculation when SRTT >= 8 and actual RTT < 8 ms #161

Open
cgutman opened this issue May 16, 2021 · 0 comments · May be fixed by #162
Open

Incorrect SRTT calculation when SRTT >= 8 and actual RTT < 8 ms #161

cgutman opened this issue May 16, 2021 · 0 comments · May be fixed by #162

Comments

@cgutman
Copy link

cgutman commented May 16, 2021

The SRTT and RTT variance logic (shown below) does not properly handle the case where the peer->roundTripTime >= 8 and roundTripTime < 8.

enet/protocol.c

Lines 863 to 876 in cf735e6

peer -> roundTripTimeVariance -= peer -> roundTripTimeVariance / 4;
if (roundTripTime >= peer -> roundTripTime)
{
enet_uint32 diff = roundTripTime - peer -> roundTripTime;
peer -> roundTripTimeVariance += diff / 4;
peer -> roundTripTime += diff / 8;
}
else
{
enet_uint32 diff = peer -> roundTripTime - roundTripTime;
peer -> roundTripTimeVariance += diff / 4;
peer -> roundTripTime -= diff / 8;
}

In this case, what will happen is diff will be < 7, so diff / 8 will be 0. As a result, peer -> roundTripTime -= diff / 8; will never result in the SRTT decreasing.

The effect of this bug is that the SRTT is effectively latched at 8 ms if it has ever exceeded 8 ms, even if the actual RTT has dropped back below 8 ms.

The RTT variance is also affected by a similar bug when peer -> roundTripTimeVariance is < 4, because peer -> roundTripTimeVariance / 4 will be 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant