Skip to content

Commit

Permalink
fix wait-time calculation according first-ttl (ticking too fast with …
Browse files Browse the repository at this point in the history
…first-ttl close to target-ttl)
  • Loading branch information
yvs2014 committed Mar 14, 2023
1 parent 56fe6c4 commit f89c170
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions ui/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,14 @@ static int numhosts = 10;
/* return the number of microseconds to wait before sending the next
ping */
int calc_deltatime(
float waittime)
struct mtr_ctl *ctl)
{
waittime /= numhosts;
float waittime = ctl->WaitTime;
int n = numhosts;
int f = ctl->fstTTL - 1;
if ((f > 0) && (n > f))
n -= f;
waittime /= n;
return 1000000 * waittime;
}

Expand Down
2 changes: 1 addition & 1 deletion ui/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ extern void net_end_transit(
void);

extern int calc_deltatime(
float WaitTime);
struct mtr_ctl *ctl);

extern int net_returned(
int at);
Expand Down
2 changes: 1 addition & 1 deletion ui/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void select_loop(
gettimeofday(&lasttime, NULL);

while (1) {
dt = calc_deltatime(ctl->WaitTime);
dt = calc_deltatime(ctl);
intervaltime.tv_sec = dt / 1000000;
intervaltime.tv_usec = dt % 1000000;

Expand Down

0 comments on commit f89c170

Please sign in to comment.