Skip to content

Commit

Permalink
Fixed function implementation (esnet#775)
Browse files Browse the repository at this point in the history
* Fixed implementation of function set_test-reverse().

* Correct/improve some other checks
  • Loading branch information
LikHait authored and bmah888 committed Aug 14, 2018
1 parent cf1f1a3 commit da6eebb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ void
iperf_set_test_reverse(struct iperf_test *ipt, int reverse)
{
ipt->reverse = reverse;
if (ipt->role == 'c')
ipt->sender = 1;
else
ipt->sender = 0;
if (ipt->reverse)
ipt->sender = ! ipt->sender;
check_sender_has_retransmits(ipt);
Expand Down Expand Up @@ -2497,7 +2501,7 @@ iperf_reset_stats(struct iperf_test *test)
rp->bytes_sent_omit = rp->bytes_sent;
rp->bytes_received = 0;
rp->bytes_sent_this_interval = rp->bytes_received_this_interval = 0;
if (test->sender && test->sender_has_retransmits) {
if (test->sender_has_retransmits == 1) {
struct iperf_interval_results ir; /* temporary results structure */
save_tcpinfo(sp, &ir);
rp->stream_prev_total_retrans = get_total_retransmits(&ir);
Expand Down Expand Up @@ -2541,7 +2545,7 @@ iperf_stats_callback(struct iperf_test *test)
if (test->protocol->id == Ptcp) {
if ( has_tcpinfo()) {
save_tcpinfo(sp, &temp);
if (test->sender && test->sender_has_retransmits) {
if (test->sender_has_retransmits == 1) {
long total_retrans = get_total_retransmits(&temp);
temp.interval_retrans = total_retrans - rp->stream_prev_total_retrans;
rp->stream_retrans += temp.interval_retrans;
Expand Down Expand Up @@ -2677,7 +2681,7 @@ iperf_print_intermediate(struct iperf_test *test)
}
bytes += irp->bytes_transferred;
if (test->protocol->id == Ptcp) {
if (test->sender && test->sender_has_retransmits) {
if (test->sender_has_retransmits == 1) {
retransmits += irp->interval_retrans;
}
} else {
Expand All @@ -2701,7 +2705,7 @@ iperf_print_intermediate(struct iperf_test *test)
start_time = timeval_diff(&sp->result->start_time,&irp->interval_start_time);
end_time = timeval_diff(&sp->result->start_time,&irp->interval_end_time);
if (test->protocol->id == Ptcp || test->protocol->id == Psctp) {
if (test->sender && test->sender_has_retransmits) {
if (test->sender_has_retransmits == 1) {
/* 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)); /* XXX irp->omitted or test->omitting? */
Expand Down Expand Up @@ -3210,7 +3214,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 || test->protocol->id == Psctp) {
if (test->sender && test->sender_has_retransmits)
if (test->sender_has_retransmits == 1)
iperf_printf(test, "%s", report_bw_retrans_cwnd_header);
else
iperf_printf(test, "%s", report_bw_header);
Expand Down Expand Up @@ -3238,7 +3242,7 @@ print_interval_results(struct iperf_test *test, struct iperf_stream *sp, cJSON *
et = timeval_diff(&sp->result->start_time, &irp->interval_end_time);

if (test->protocol->id == Ptcp || test->protocol->id == Psctp) {
if (test->sender && test->sender_has_retransmits) {
if (test->sender_has_retransmits == 1) {
/* Interval, TCP with retransmits. */
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 rtt: %d rttvar: %d pmtu: %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, (int64_t) irp->rtt, (int64_t) irp->rttvar, (int64_t) irp->pmtu, irp->omitted));
Expand Down

0 comments on commit da6eebb

Please sign in to comment.