Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the occasionally false RTT issue. #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ int rtt(int *seqp, int recvport, float *ms_delay)
status = delaytable[tablepos].status;
delaytable[tablepos].status = S_RECV;

sec_delay = time(NULL) - delaytable[tablepos].sec;
usec_delay = get_usec() - delaytable[tablepos].usec;
struct timeval tv;
gettimeofday(&tv, NULL);
sec_delay = tv.tv_sec - delaytable[tablepos].sec;
usec_delay = tv.tv_usec - delaytable[tablepos].usec;
if (sec_delay == 0 && usec_delay < 0)
usec_delay += 1000000;

Expand Down
21 changes: 15 additions & 6 deletions sendicmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ void send_icmp_echo(void)
icmp->checksum = icmp_cksum;

/* adds this pkt in delaytable */
if (opt_icmptype == ICMP_ECHO)
delaytable_add(_icmp_seq, 0, time(NULL), get_usec(), S_SENT);
if (opt_icmptype == ICMP_ECHO) {
struct timeval tv;
gettimeofday(&tv, NULL);
delaytable_add(_icmp_seq, 0, tv.tv_sec, tv.tv_usec, S_SENT);
}

/* send packet */
send_ip_handler(packet, ICMPHDR_SIZE + data_size);
Expand Down Expand Up @@ -140,8 +143,11 @@ void send_icmp_timestamp(void)
icmp->checksum = icmp_cksum;

/* adds this pkt in delaytable */
if (opt_icmptype == ICMP_TIMESTAMP)
delaytable_add(_icmp_seq, 0, time(NULL), get_usec(), S_SENT);
if (opt_icmptype == ICMP_TIMESTAMP) {
struct timeval tv;
gettimeofday(&tv, NULL);
delaytable_add(_icmp_seq, 0, tv.tv_sec, tv.tv_usec, S_SENT);
}

/* send packet */
send_ip_handler(packet, ICMPHDR_SIZE + sizeof(struct icmp_tstamp_data));
Expand Down Expand Up @@ -180,8 +186,11 @@ void send_icmp_address(void)
icmp->checksum = icmp_cksum;

/* adds this pkt in delaytable */
if (opt_icmptype == ICMP_TIMESTAMP)
delaytable_add(_icmp_seq, 0, time(NULL), get_usec(), S_SENT);
if (opt_icmptype == ICMP_TIMESTAMP) {
struct timeval tv;
gettimeofday(&tv, NULL);
delaytable_add(_icmp_seq, 0, tv.tv_sec, tv.tv_usec, S_SENT);
}

/* send packet */
send_ip_handler(packet, ICMPHDR_SIZE + 4);
Expand Down
4 changes: 3 additions & 1 deletion sendtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ void send_tcp(void)
#endif

/* adds this pkt in delaytable */
delaytable_add(sequence, src_port, time(NULL), get_usec(), S_SENT);
struct timeval tv;
gettimeofday(&tv, NULL);
delaytable_add(sequence, src_port, tv.tv_sec, tv.tv_usec, S_SENT);

/* send packet */
send_ip_handler(packet+PSEUDOHDR_SIZE, packet_size);
Expand Down
4 changes: 3 additions & 1 deletion sendudp.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ void send_udp(void)
#endif

/* adds this pkt in delaytable */
delaytable_add(sequence, src_port, time(NULL), get_usec(), S_SENT);
struct timeval tv;
gettimeofday(&tv, NULL);
delaytable_add(sequence, src_port, tv.tv_sec, tv.tv_usec, S_SENT);

/* send packet */
send_ip_handler(packet+PSEUDOHDR_SIZE, packet_size);
Expand Down