[Spice-devel] server: net_test: put a limit on the calculated bitrate #698225

Submitted by Uri Lublin on Oct. 11, 2012, 8:50 a.m.

Details

Message ID af9f0f3b8e86e5d4779392a9af0d2e1428be53b0.1349945372.git.uril@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin Oct. 11, 2012, 8:50 a.m.
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(-)

Patch hide | download patch | download mbox

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,

Comments

ACK.

On 10/11/2012 10:50 AM, Uri Lublin wrote:
> 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,
>
On 10/11/2012 10:50 AM, Uri Lublin wrote:
> 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).

self-nack.

This message can still be confusing if e.g. a network is 1Gb and we 
report 10Gb.