mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-27 07:29:32 +00:00
channel: cap roundtrip using Linux information if available
Linux kernel already compute roundtrip. If available use it to limit discovered one. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
680cab338e
commit
c84dc2e04c
@ -19,6 +19,7 @@
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <common/generated_server_marshallers.h>
|
||||
|
||||
#include "main-channel-client.h"
|
||||
@ -464,9 +465,34 @@ void main_channel_client_handle_migrate_dst_do_seamless(MainChannelClient *mcc,
|
||||
SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
static uint64_t reds_stream_rtt(const RedsStream *stream)
|
||||
{
|
||||
if (!stream || stream->socket < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct tcp_info ti;
|
||||
socklen_t ti_len = sizeof(ti);
|
||||
if (getsockopt(stream->socket, SOL_TCP, TCP_INFO, &ti, &ti_len)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "RCV RTT %u\n", ti.tcpi_rttvar);
|
||||
fprintf(stderr, "RCV MTU %u\n", ti.tcpi_pmtu);
|
||||
return ti.tcpi_rtt;
|
||||
}
|
||||
#else
|
||||
static inline uint64_t reds_stream_rtt(const RedsStream *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping, uint32_t size)
|
||||
{
|
||||
uint64_t roundtrip;
|
||||
uint64_t roundtrip, rtt;
|
||||
RedChannelClient* rcc = RED_CHANNEL_CLIENT(mcc);
|
||||
|
||||
roundtrip = g_get_monotonic_time() - ping->timestamp;
|
||||
@ -491,6 +517,10 @@ void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping,
|
||||
mcc->priv->latency = MIN(mcc->priv->latency, roundtrip);
|
||||
break;
|
||||
case NET_TEST_STAGE_RATE:
|
||||
rtt = reds_stream_rtt(red_channel_client_get_stream(rcc));
|
||||
if (rtt)
|
||||
mcc->priv->latency = MIN(mcc->priv->latency, rtt);
|
||||
|
||||
mcc->priv->net_test_id = 0;
|
||||
if (roundtrip <= mcc->priv->latency) {
|
||||
// probably high load on client or server result with incorrect values
|
||||
|
||||
Loading…
Reference in New Issue
Block a user