[Spice-devel] [master PATCH 1/2] server: netstat: modify network bandwidth calculation

Uri Lublin uril at redhat.com
Tue Oct 18 10:20:14 PDT 2011


Currently spice-server network bandwidth estimation is:
  send an empty ping packet to the client (and ignore it) ("warmup")
  send an empty ping packet and calculate time till pong is received ("latency")
  send a ping packet with data (256KB) and calculate time till pong  ("roundtrip")
  bandwidth = datasize / (roundtip - latency)

Many times (e.g. fast LAN), "(roundtrip - latency)" is very small.
This results with a falsely very high bandwidth.

This patch makes the bandwidth calculation be
  bandwidth = datasize / roundtrip

Suggested by Marc-André Lureau <marcandre.lureau at redhat.com>
---
 server/main_channel.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/server/main_channel.c b/server/main_channel.c
index 43c0f3f..a4db724 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -812,7 +812,7 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
                     break;
                 }
                 mcc->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
-                                        / (roundtrip - mcc->latency);
+                                        / roundtrip;
                 red_printf("net test: latency %f ms, bitrate %lu bps (%f Mbps)%s",
                            (double)mcc->latency / 1000,
                            mcc->bitrate_per_sec,
-- 
1.7.6.4



More information about the Spice-devel mailing list