Skip to content

Commit

Permalink
Output TCP snd_cwnd (on platforms supporting it) in normal output.
Browse files Browse the repository at this point in the history
We were computing and printing this in JSON output mode anyway; this
change just exposes this quantity in a human-friendly manner (better
than the first attempt at this) when doing normal output.

Resolves Issue 99 (Additional TCP_INFO items).
  • Loading branch information
bmah888 committed Feb 14, 2014
1 parent 4addea8 commit d076653
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,9 +1848,9 @@ iperf_print_intermediate(struct iperf_test *test)
if (test->sender && test->sender_has_retransmits) {
/* Interval sum, TCP with retransmits. */
if (test->json_output)
cJSON_AddItemToObject(json_interval, "sum", iperf_json_printf("start: %f end: %f seconds: %f bytes: %d bits_per_second: %f retransmits: %d omitted: %b", (double) start_time, (double) end_time, (double) irp->interval_duration, (int64_t) bytes, bandwidth * 8, (int64_t) retransmits, irp->omitted));
cJSON_AddItemToObject(json_interval, "sum", iperf_json_printf("start: %f end: %f seconds: %f bytes: %d bits_per_second: %f retransmits: %d omitted: %b", (double) start_time, (double) end_time, (double) irp->interval_duration, (int64_t) bytes, bandwidth * 8, (int64_t) retransmits, irp->omitted)); /* XXX irp->omitted or test->omitting? */
else
iprintf(test, report_sum_bw_retrans_format, start_time, end_time, ubuf, nbuf, retransmits, irp->omitted?report_omitted:"");
iprintf(test, report_sum_bw_retrans_format, start_time, end_time, ubuf, nbuf, retransmits, irp->omitted?report_omitted:""); /* XXX irp->omitted or test->omitting? */
} else {
/* Interval sum, TCP without retransmits. */
if (test->json_output)
Expand Down Expand Up @@ -2066,6 +2066,7 @@ print_interval_results(struct iperf_test *test, struct iperf_stream *sp, cJSON *
{
char ubuf[UNIT_LEN];
char nbuf[UNIT_LEN];
char cbuf[UNIT_LEN];
double st = 0., et = 0.;
struct iperf_interval_results *irp = NULL;
double bandwidth, lost_percent;
Expand All @@ -2085,7 +2086,7 @@ print_interval_results(struct iperf_test *test, struct iperf_stream *sp, cJSON *
if (timeval_equals(&sp->result->start_time, &irp->interval_start_time)) {
if (test->protocol->id == Ptcp) {
if (test->sender && test->sender_has_retransmits)
iprintf(test, "%s", report_bw_retrans_header);
iprintf(test, "%s", report_bw_retrans_cwnd_header);
else
iprintf(test, "%s", report_bw_header);
} else {
Expand All @@ -2112,7 +2113,8 @@ print_interval_results(struct iperf_test *test, struct iperf_stream *sp, cJSON *
if (test->json_output)
cJSON_AddItemToArray(json_interval_streams, iperf_json_printf("socket: %d start: %f end: %f seconds: %f bytes: %d bits_per_second: %f retransmits: %d snd_cwnd: %d omitted: %b", (int64_t) sp->socket, (double) st, (double) et, (double) irp->interval_duration, (int64_t) irp->bytes_transferred, bandwidth * 8, (int64_t) irp->interval_retrans, (int64_t) irp->snd_cwnd, irp->omitted));
else
iprintf(test, report_bw_retrans_format, sp->socket, st, et, ubuf, nbuf, irp->interval_retrans, irp->omitted?report_omitted:"");
unit_snprintf(cbuf, UNIT_LEN, irp->snd_cwnd, 'A');
iprintf(test, report_bw_retrans_cwnd_format, sp->socket, st, et, ubuf, nbuf, irp->interval_retrans, cbuf, irp->omitted?report_omitted:"");
} else {
/* Interval, TCP without retransmits. */
if (test->json_output)
Expand Down
14 changes: 10 additions & 4 deletions src/locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,23 @@ const char report_bw_header[] =
const char report_bw_retrans_header[] =
"[ ID] Interval Transfer Bandwidth Retr\n";

const char report_bw_retrans_cwnd_header[] =
"[ ID] Interval Transfer Bandwidth Retr Cwnd\n";

const char report_bw_udp_header[] =
"[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams\n";

const char report_bw_udp_sender_header[] =
"[ ID] Interval Transfer Bandwidth Total Datagrams\n";

const char report_bw_format[] =
"[%3d] %6.2f-%-6.2f sec %ss %ss/sec %s\n";
"[%3d] %6.2f-%-6.2f sec %ss %ss/sec %s\n";

const char report_bw_retrans_format[] =
"[%3d] %6.2f-%-6.2f sec %ss %ss/sec %3d %s\n";
"[%3d] %6.2f-%-6.2f sec %ss %ss/sec %3u %s\n";

const char report_bw_retrans_cwnd_format[] =
"[%3d] %6.2f-%-6.2f sec %ss %ss/sec %3u %ss %s\n";

const char report_bw_udp_format[] =
"[%3d] %6.2f-%-6.2f sec %ss %ss/sec %5.3f ms %d/%d (%.2g%%) %s\n";
Expand All @@ -257,10 +263,10 @@ const char report_summary[] =
"Test Complete. Summary Results:\n";

const char report_sum_bw_format[] =
"[SUM] %6.2f-%-6.2f sec %ss %ss/sec %s\n";
"[SUM] %6.2f-%-6.2f sec %ss %ss/sec %s\n";

const char report_sum_bw_retrans_format[] =
"[SUM] %6.2f-%-6.2f sec %ss %ss/sec %3d %s\n";
"[SUM] %6.2f-%-6.2f sec %ss %ss/sec %3d %s\n";

const char report_sum_bw_udp_format[] =
"[SUM] %6.2f-%-6.2f sec %ss %ss/sec %5.3f ms %d/%d (%.2g%%) %s\n";
Expand Down
4 changes: 3 additions & 1 deletion src/locale.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2011, The Regents of the University of California,
* Copyright (c) 2009-2014, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
Expand Down Expand Up @@ -46,10 +46,12 @@ extern const char report_read_lengths[] ;
extern const char report_read_length_times[] ;
extern const char report_bw_header[] ;
extern const char report_bw_retrans_header[] ;
extern const char report_bw_retrans_cwnd_header[] ;
extern const char report_bw_udp_header[] ;
extern const char report_bw_udp_sender_header[] ;
extern const char report_bw_format[] ;
extern const char report_bw_retrans_format[] ;
extern const char report_bw_retrans_cwnd_format[] ;
extern const char report_bw_udp_format[] ;
extern const char report_bw_udp_sender_format[] ;
extern const char report_summary[] ;
Expand Down
8 changes: 7 additions & 1 deletion src/tcp_info.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013, The Regents of the University of California,
* Copyright (c) 2009-2014, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
Expand Down Expand Up @@ -81,6 +81,12 @@ save_tcpinfo(struct iperf_stream *sp, struct iperf_interval_results *irp)

if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *)&irp->tcpInfo, &tcp_info_length) < 0)
iperf_err(sp->test, "getsockopt - %s", strerror(errno));

if (sp->test->debug) {
printf("tcpi_snd_cwnd %u tcpi_snd_mss %u\n",
irp->tcpInfo.tcpi_snd_cwnd, irp->tcpInfo.tcpi_snd_mss);
}

#endif
}

Expand Down

0 comments on commit d076653

Please sign in to comment.