[PATCH] server: net_test: put a limit on the calculated bitrate #698225

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When calculating bitrate of a local connection, the result can be too high.
That happens when "roundtrip" and "latency" are very close, which only
happens on fast networks. The decision that we are not in WAN network
is correct, but the calculated number shown in the log message is not.

This patch puts a limit to the bitrate, such that it does not change the
decision but is an acceptable number to see in logs (specifically 10Gb).
---
 server/main_channel.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/server/main_channel.c b/server/main_channel.c
index 0fd5ab6..80fbfb3 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -52,6 +52,8 @@
 #define NET_TEST_WARMUP_BYTES 0
 #define NET_TEST_BYTES (1024 * 250)
 
+#define NET_TEST_MAX_BITRATE ((uint64_t)10 * 1024 * 1024 * 1024)
+
 #define PING_INTERVAL (1000 * 10)
 
 static uint8_t zero_page[ZERO_BUF_SIZE] = {0};
@@ -971,6 +973,7 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
                 }
                 mcc->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
                                         / (roundtrip - mcc->latency);
+                mcc->bitrate_per_sec = MIN(mcc->bitrate_per_sec, NET_TEST_MAX_BITRATE);
                 spice_printerr("net test: latency %f ms, bitrate %"PRIu64" bps (%f Mbps)%s",
                            (double)mcc->latency / 1000,
                            mcc->bitrate_per_sec,
-- 
1.7.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]