From 4f04ebbb57e13b6621dc9b1bc0667a4e5b8cb465 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 20 Sep 2018 16:35:37 +0200 Subject: [PATCH] Estimate higher bandwidth in slow start If we are still in slow start then we haven't discovered the actual bandwidth limit yet. We also rely on the caller causing a bit of congestion to detect the limit. So report a higher bandwidth estimate than what we've currently tested in this scenario. --- common/rfb/Congestion.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/common/rfb/Congestion.cxx b/common/rfb/Congestion.cxx index 8162808b..4a784522 100644 --- a/common/rfb/Congestion.cxx +++ b/common/rfb/Congestion.cxx @@ -291,11 +291,20 @@ int Congestion::getUncongestedETA() size_t Congestion::getBandwidth() { + size_t bandwidth; + // No measurements yet? Guess RTT of 60 ms if (safeBaseRTT == (unsigned)-1) - return congWindow * 1000 / 60; + bandwidth = congWindow * 1000 / 60; + else + bandwidth = congWindow * 1000 / safeBaseRTT; + + // We're still probing so guess actual bandwidth is halfway between + // the current guess and the next one (slow start doubles each time) + if (inSlowStart) + bandwidth = bandwidth + bandwidth / 2; - return congWindow * 1000 / safeBaseRTT; + return bandwidth; } void Congestion::debugTrace(const char* filename, int fd) -- 2.39.5