mirror of
https://github.com/yarrick/iodine.git
synced 2025-04-04 05:43:33 +03:00
option (-J0) to autodetect delay variance factor
This commit is contained in:
parent
1cbe946676
commit
0d93784715
3 changed files with 17 additions and 2 deletions
11
src/client.c
11
src/client.c
|
@ -285,6 +285,7 @@ got_response(int id, int immediate, int fail)
|
|||
{
|
||||
struct timeval now, rtt;
|
||||
time_t rtt_ms;
|
||||
static time_t rtt_min_ms = 1;
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
QTRACK_DEBUG(4, "Got answer id %d (%s)%s", id, immediate ? "immediate" : "lazy",
|
||||
|
@ -322,8 +323,16 @@ got_response(int id, int immediate, int fail)
|
|||
this.rtt_total_ms += rtt_ms;
|
||||
this.num_immediate++;
|
||||
|
||||
if (this.autodetect_server_timeout)
|
||||
if (this.autodetect_server_timeout) {
|
||||
if (this.autodetect_delay_variance) {
|
||||
if (rtt_ms > 0 && (rtt_ms < rtt_min_ms || 1 == rtt_min_ms)) {
|
||||
rtt_min_ms = rtt_ms;
|
||||
}
|
||||
this.downstream_delay_variance = (double) (this.rtt_total_ms /
|
||||
this.num_immediate) / rtt_min_ms;
|
||||
}
|
||||
update_server_timeout(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove query info from buffer to mark it as answered */
|
||||
|
|
|
@ -90,6 +90,7 @@ struct client_instance {
|
|||
time_t downstream_timeout_ms;
|
||||
double downstream_delay_variance;
|
||||
int autodetect_server_timeout;
|
||||
int autodetect_delay_variance;
|
||||
|
||||
/* Cumulative Round-Trip-Time in ms */
|
||||
time_t rtt_total_ms;
|
||||
|
|
|
@ -83,6 +83,7 @@ struct client_instance this;
|
|||
.num_immediate = 1, \
|
||||
.rtt_total_ms = 200, \
|
||||
.downstream_delay_variance = 2.0, \
|
||||
.autodetect_delay_variance = 0, \
|
||||
.remote_forward_addr = {.ss_family = AF_UNSPEC}
|
||||
|
||||
static struct client_instance preset_default = {
|
||||
|
@ -265,7 +266,7 @@ help()
|
|||
fprintf(stderr, " -W upstream fragment window size (default: 8 frags)\n");
|
||||
fprintf(stderr, " -i server-side request timeout in lazy mode (default: auto)\n");
|
||||
fprintf(stderr, " -j downstream fragment ACK timeout, implies -i4 (default: 2 sec)\n");
|
||||
fprintf(stderr, " -J downstream fragment ACK delay variance factor (default: 2.0)\n");
|
||||
fprintf(stderr, " -J downstream fragment ACK delay variance factor (default: 2.0), 0: auto\n");
|
||||
//fprintf(stderr, " --nodrop disable TCP packet-dropping optimisations\n");
|
||||
fprintf(stderr, " -c 1: use downstream compression (default), 0: disable\n");
|
||||
fprintf(stderr, " -C 1: use upstream compression (default), 0: disable\n\n");
|
||||
|
@ -577,6 +578,10 @@ main(int argc, char **argv)
|
|||
break;
|
||||
case 'J':
|
||||
this.downstream_delay_variance = strtod(optarg, NULL);
|
||||
if (0.0 == this.downstream_delay_variance) {
|
||||
this.autodetect_delay_variance = 1;
|
||||
this.downstream_delay_variance = 2.0;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
this.send_interval_ms = atoi(optarg);
|
||||
|
|
Loading…
Add table
Reference in a new issue