mirror of
https://github.com/lsalzman/enet
synced 2024-11-21 14:29:05 -07:00
round RTT stats before comparing
This commit is contained in:
parent
bde113ef56
commit
65dc0f74d8
1 changed files with 13 additions and 7 deletions
20
protocol.c
20
protocol.c
|
@ -838,6 +838,7 @@ static int
|
||||||
enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer * peer, const ENetProtocol * command)
|
enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer * peer, const ENetProtocol * command)
|
||||||
{
|
{
|
||||||
enet_uint32 roundTripTime,
|
enet_uint32 roundTripTime,
|
||||||
|
roundTripTimeVariance,
|
||||||
receivedSentTime,
|
receivedSentTime,
|
||||||
receivedReliableSequenceNumber;
|
receivedReliableSequenceNumber;
|
||||||
ENetProtocolCommand commandNumber;
|
ENetProtocolCommand commandNumber;
|
||||||
|
@ -871,26 +872,31 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer *
|
||||||
peer -> roundTripTimeRemainder = accumRoundTripTime & 0xFF;
|
peer -> roundTripTimeRemainder = accumRoundTripTime & 0xFF;
|
||||||
peer -> roundTripTimeVariance = accumRoundTripTimeVariance >> 8;
|
peer -> roundTripTimeVariance = accumRoundTripTimeVariance >> 8;
|
||||||
peer -> roundTripTimeVarianceRemainder = accumRoundTripTimeVariance & 0xFF;
|
peer -> roundTripTimeVarianceRemainder = accumRoundTripTimeVariance & 0xFF;
|
||||||
|
|
||||||
|
roundTripTime = (accumRoundTripTime + 128) >> 8;
|
||||||
|
roundTripTimeVariance = (accumRoundTripTimeVariance + 255) >> 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
roundTripTimeVariance = (roundTripTime + 1) / 2;
|
||||||
|
|
||||||
peer -> roundTripTime = roundTripTime;
|
peer -> roundTripTime = roundTripTime;
|
||||||
peer -> roundTripTimeVariance = (roundTripTime + 1) / 2;
|
peer -> roundTripTimeVariance = roundTripTimeVariance;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer -> roundTripTime < peer -> lowestRoundTripTime)
|
if (roundTripTime < peer -> lowestRoundTripTime)
|
||||||
peer -> lowestRoundTripTime = peer -> roundTripTime;
|
peer -> lowestRoundTripTime = roundTripTime;
|
||||||
|
|
||||||
if (peer -> roundTripTimeVariance > peer -> highestRoundTripTimeVariance)
|
if (roundTripTimeVariance > peer -> highestRoundTripTimeVariance)
|
||||||
peer -> highestRoundTripTimeVariance = peer -> roundTripTimeVariance;
|
peer -> highestRoundTripTimeVariance = roundTripTimeVariance;
|
||||||
|
|
||||||
if (peer -> packetThrottleEpoch == 0 ||
|
if (peer -> packetThrottleEpoch == 0 ||
|
||||||
ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> packetThrottleEpoch) >= peer -> packetThrottleInterval)
|
ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> packetThrottleEpoch) >= peer -> packetThrottleInterval)
|
||||||
{
|
{
|
||||||
peer -> lastRoundTripTime = peer -> lowestRoundTripTime;
|
peer -> lastRoundTripTime = peer -> lowestRoundTripTime;
|
||||||
peer -> lastRoundTripTimeVariance = ENET_MAX (peer -> highestRoundTripTimeVariance, (peer -> lowestRoundTripTime + 15) / 16);
|
peer -> lastRoundTripTimeVariance = ENET_MAX (peer -> highestRoundTripTimeVariance, (peer -> lowestRoundTripTime + 15) / 16);
|
||||||
peer -> lowestRoundTripTime = peer -> roundTripTime;
|
peer -> lowestRoundTripTime = roundTripTime;
|
||||||
peer -> highestRoundTripTimeVariance = ENET_MAX (peer -> roundTripTimeVariance, 2);
|
peer -> highestRoundTripTimeVariance = ENET_MAX (roundTripTimeVariance, 2);
|
||||||
peer -> packetThrottleEpoch = host -> serviceTime;
|
peer -> packetThrottleEpoch = host -> serviceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue