Only use timesstamps from received packets.

keeping track of the sent packets would require a list of paquets
we're waiting for. This is overkill.
This commit is contained in:
Matthieu Herrb 2012-07-31 08:24:04 +02:00
parent e85c367e45
commit 1882a84527

View file

@ -54,8 +54,6 @@ send_packet(bool timestamp)
if (verbose) if (verbose)
warn("sendto"); warn("sendto");
} }
if (timestamp)
clock_gettime(CLOCK_REALTIME, &sent);
if (verbose > 1) if (verbose > 1)
printf("sent %d\n", seq); printf("sent %d\n", seq);
seq++; seq++;
@ -169,7 +167,8 @@ main(int argc, char *argv[])
sigaction(SIGALRM, &sa, NULL); sigaction(SIGALRM, &sa, NULL);
/* send initial packet */ /* send initial packet */
send_packet(true); gettimeofday(&sent, NULL);
send_packet(0);
while (1) { while (1) {
struct timespec now, diff; struct timespec now, diff;
@ -243,6 +242,7 @@ main(int argc, char *argv[])
} }
disconnected = 0; disconnected = 0;
last = buffer; last = buffer;
gettimeofday(&sent, NULL);
if (verbose > 1) if (verbose > 1)
printf("%d %ld.%06ld\n", buffer, (long)diff.tv_sec, printf("%d %ld.%06ld\n", buffer, (long)diff.tv_sec,
diff.tv_nsec/1000); diff.tv_nsec/1000);