Limit lossless refresh update to safe size
We don't want to waste bandwidth on the lossless refresh if we might
need that bandwidth for a normal update. Try to estimate how much
data we can safely send without interfering.
diff --git a/common/rfb/Congestion.cxx b/common/rfb/Congestion.cxx
index a2f7a25..4d36d9f 100644
--- a/common/rfb/Congestion.cxx
+++ b/common/rfb/Congestion.cxx
@@ -1,4 +1,4 @@
-/* Copyright 2009-2015 Pierre Ossman for Cendio AB
+/* Copyright 2009-2018 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -73,7 +73,7 @@
Congestion::Congestion() :
lastPosition(0), extraBuffer(0),
baseRTT(-1), congWindow(INITIAL_WINDOW), inSlowStart(true),
- measurements(0), minRTT(-1), minCongestedRTT(-1)
+ safeBaseRTT(-1), measurements(0), minRTT(-1), minCongestedRTT(-1)
{
gettimeofday(&lastUpdate, NULL);
gettimeofday(&lastSent, NULL);
@@ -170,7 +170,7 @@
// Try to estimate wire latency by tracking lowest seen latency
if (rtt < baseRTT)
- baseRTT = rtt;
+ safeBaseRTT = baseRTT = rtt;
// Pings sent before the last adjustment aren't interesting as they
// aren't a measurement of the current congestion window
@@ -284,6 +284,15 @@
}
}
+size_t Congestion::getBandwidth()
+{
+ // No measurements yet? Guess RTT of 60 ms
+ if (safeBaseRTT == (unsigned)-1)
+ return congWindow * 1000 / 60;
+
+ return congWindow * 1000 / safeBaseRTT;
+}
+
void Congestion::debugTrace(const char* filename, int fd)
{
#ifdef CONGESTION_TRACE