mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
RTT fixes (#7428)
* Few code updates * Do not show average RTT before timing out * Fix unwanted integer division in RTTStatistics * Fix float format, prettier jitter calculation * Use +=, 0.1f -> 100.0f for stronger average updates
This commit is contained in:
parent
07b1743d3d
commit
968ce9af59
5 changed files with 34 additions and 39 deletions
|
@ -437,7 +437,7 @@ void Client::step(float dtime)
|
|||
counter = 0.0;
|
||||
// connectedAndInitialized() is true, peer exists.
|
||||
float avg_rtt = getRTT();
|
||||
infostream << "Client: avg_rtt=" << avg_rtt << std::endl;
|
||||
infostream << "Client: average rtt: " << avg_rtt << std::endl;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1706,9 +1706,17 @@ void Client::afterContentReceived()
|
|||
delete[] text;
|
||||
}
|
||||
|
||||
// returns the Round Trip Time
|
||||
// if the RTT did not become updated within 2 seconds, e.g. before timing out,
|
||||
// it returns the expired time instead
|
||||
float Client::getRTT()
|
||||
{
|
||||
return m_con->getPeerStat(PEER_ID_SERVER,con::AVG_RTT);
|
||||
float avg_rtt = m_con->getPeerStat(PEER_ID_SERVER, con::AVG_RTT);
|
||||
float time_from_last_rtt =
|
||||
m_con->getPeerStat(PEER_ID_SERVER, con::TIMEOUT_COUNTER);
|
||||
if (avg_rtt + 2.0f > time_from_last_rtt)
|
||||
return avg_rtt;
|
||||
return time_from_last_rtt;
|
||||
}
|
||||
|
||||
float Client::getCurRate()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue