From 29dbc41c1d47d645f6e72f4b48f04c203a536f9b Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Thu, 23 Oct 2014 13:39:58 -0700 Subject: [PATCH] Also maintain the min and mean of the RTT. For issue #215. --- src/iperf.h | 3 +++ src/iperf_api.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/iperf.h b/src/iperf.h index 7d5c1e3..15e7ddb 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -91,6 +91,9 @@ struct iperf_stream_result int stream_prev_total_sacks; int stream_sacks; int stream_max_rtt; + int stream_min_rtt; + int stream_sum_rtt; + int stream_count_rtt; int stream_max_snd_cwnd; struct timeval start_time; struct timeval end_time; diff --git a/src/iperf_api.c b/src/iperf_api.c index 7833ee7..f56d775 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -2023,10 +2023,17 @@ iperf_stats_callback(struct iperf_test *test) if (temp.snd_cwnd > rp->stream_max_snd_cwnd) { rp->stream_max_snd_cwnd = temp.snd_cwnd; } + temp.rtt = get_rtt(&temp); if (temp.rtt > rp->stream_max_rtt) { rp->stream_max_rtt = temp.rtt; } + if (rp->stream_min_rtt == 0 || + temp.rtt < rp->stream_min_rtt) { + rp->stream_min_rtt = temp.rtt; + } + rp->stream_sum_rtt += temp.rtt; + rp->stream_count_rtt++; } } } else { @@ -2233,7 +2240,7 @@ iperf_print_results(struct iperf_test *test) if (test->sender_has_retransmits) { /* Summary, TCP with retransmits. */ if (test->json_output) - cJSON_AddItemToObject(json_summary_stream, "sender", iperf_json_printf("socket: %d start: %f end: %f seconds: %f bytes: %d bits_per_second: %f retransmits: %d max_snd_cwnd: %d max_rtt: %d", (int64_t) sp->socket, (double) start_time, (double) end_time, (double) end_time, (int64_t) bytes_sent, bandwidth * 8, (int64_t) sp->result->stream_retrans, (int64_t) sp->result->stream_max_snd_cwnd, (int64_t) sp->result->stream_max_rtt)); + cJSON_AddItemToObject(json_summary_stream, "sender", iperf_json_printf("socket: %d start: %f end: %f seconds: %f bytes: %d bits_per_second: %f retransmits: %d max_snd_cwnd: %d max_rtt: %d min_rtt: %d mean_rtt: %d", (int64_t) sp->socket, (double) start_time, (double) end_time, (double) end_time, (int64_t) bytes_sent, bandwidth * 8, (int64_t) sp->result->stream_retrans, (int64_t) sp->result->stream_max_snd_cwnd, (int64_t) sp->result->stream_max_rtt, (int64_t) sp->result->stream_min_rtt, (int64_t) ((sp->result->stream_count_rtt == 0) ? 0 : sp->result->stream_sum_rtt / sp->result->stream_count_rtt))); else iprintf(test, report_bw_retrans_format, sp->socket, start_time, end_time, ubuf, nbuf, sp->result->stream_retrans, report_sender); } else {