summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authoryou <ovvv@web.de>2018-06-23 09:16:01 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-06-23 09:16:01 +0200
commit968ce9af598024ec71e9ffb2d15c3997a13ad754 (patch)
tree0ad28040f1deb3ca1885d5147b23931d237a76f5 /src/client.cpp
parent07b1743d3db086f0f984968252d9e3ac71336a7e (diff)
downloadminetest-968ce9af598024ec71e9ffb2d15c3997a13ad754.tar.gz
minetest-968ce9af598024ec71e9ffb2d15c3997a13ad754.tar.bz2
minetest-968ce9af598024ec71e9ffb2d15c3997a13ad754.zip
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
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 18e43b1b6..09c67c268 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -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()