diff --git a/src/iperf.h b/src/iperf.h index 9beec09..0b165e8 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -119,19 +119,19 @@ struct iperf_test /* boolen variables for Options */ - int reverse; /* -R option */ int daemon; /* -D option */ + int debug; /* -d option - debug mode */ int no_delay; /* -N option */ - int print_mss; /* -m option */ - int v6domain; /* -6 option */ int output_format; /* -O option */ - int verbose; /* -V (verbose) option */ - int debug; /* debug mode */ + int print_mss; /* -m option */ + int reverse; /* -R option */ + int tcp_info; /* -T option - display getsockopt(TCP_INFO) results. */ + int v6domain; /* -6 option */ + int verbose; /* -V option - verbose mode */ /* Select related parameters */ int max_fd; fd_set read_set; /* set of read sockets */ - fd_set temp_set; /* temp set for select */ fd_set write_set; /* set of write sockets */ int (*accept) (struct iperf_test *); @@ -142,12 +142,7 @@ struct iperf_test void (*stats_callback) (struct iperf_test *); void (*reporter_callback) (struct iperf_test *); - /* result string */ - char *result_str; - - int reporter_fd; /* file descriptor for reporter */ int num_streams; /* total streams in the test (-P) */ - int tcp_info; /* display getsockopt(TCP_INFO) results. Should this be moved to Options? */ /* iperf error reporting * - errtype: (0,1,2) diff --git a/src/iperf_api.c b/src/iperf_api.c index e9461ff..bb2fdd5 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -177,12 +177,12 @@ iperf_send(struct iperf_test *test) free_timer(stats_interval); free_timer(reporter_interval); - // Send TEST_DONE (ALL_STREAMS_END) message test->state = TEST_END; if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { perror("write TEST_END"); return -1; } + test->stats_callback(test); } } } @@ -253,11 +253,6 @@ package_parameters(struct iperf_test *test) strcat(pstring, optbuf); } - if (test->default_settings->unit_format) { - sprintf(optbuf, "-f %c ", test->default_settings->unit_format); - strcat(pstring, optbuf); - } - if (strcmp(test->default_settings->cookie, "") != 0) { sprintf(optbuf, "-C %s ", test->default_settings->cookie); strcat(pstring, optbuf); @@ -325,9 +320,6 @@ parse_parameters(struct iperf_test *test) case 'w': test->default_settings->socket_bufsize = atoi(optarg); break; - case 'f': - test->default_settings->unit_format = *optarg; - break; case 'C': memcpy(test->default_settings->cookie, optarg, COOKIE_SIZE); break; @@ -655,7 +647,6 @@ iperf_defaults(struct iperf_test * testp) testp->stats_interval = 0; testp->reporter_interval = 0; testp->num_streams = 1; - testp->result_str = NULL; testp->default_settings->unit_format = 'a'; testp->default_settings->socket_bufsize = 0; /* use autotuning */ @@ -885,6 +876,8 @@ iperf_reporter_callback(struct iperf_test * test) case DISPLAY_RESULTS: /* print final summary for all intervals */ + printf(report_bw_header); + start_time = 0.; sp = test->streams; end_time = timeval_diff(&sp->result->start_time, &sp->result->end_time); @@ -902,7 +895,8 @@ iperf_reporter_callback(struct iperf_test * test) if (bytes_sent > 0) { unit_snprintf(ubuf, UNIT_LEN, (double) (bytes_sent), 'A'); unit_snprintf(nbuf, UNIT_LEN, (double) (bytes_sent / end_time), test->default_settings->unit_format); - if (test->protocol == Ptcp) { + if (test->protocol == Ptcp) { + printf(" Sent\n"); printf(report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf); #if defined(linux) || defined(__FreeBSD__) @@ -926,6 +920,7 @@ iperf_reporter_callback(struct iperf_test * test) unit_snprintf(ubuf, UNIT_LEN, (double) bytes_received, 'A'); unit_snprintf(nbuf, UNIT_LEN, (double) (bytes_received / end_time), test->default_settings->unit_format); if (test->protocol == Ptcp) { + printf(" Received\n"); printf(report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf); } } @@ -935,11 +930,11 @@ iperf_reporter_callback(struct iperf_test * test) unit_snprintf(ubuf, UNIT_LEN, (double) total_sent, 'A'); unit_snprintf(nbuf, UNIT_LEN, (double) total_sent / end_time, test->default_settings->unit_format); if (test->protocol == Ptcp) { - printf("[MSG] Total sent\n"); + printf(" Total sent\n"); printf(report_sum_bw_format, start_time, end_time, ubuf, nbuf); unit_snprintf(ubuf, UNIT_LEN, (double) total_received, 'A'); unit_snprintf(nbuf, UNIT_LEN, (double) (total_received / end_time), test->default_settings->unit_format); - printf("[MSG] Total received\n"); + printf(" Total received\n"); printf(report_sum_bw_format, start_time, end_time, ubuf, nbuf); } else { printf(report_sum_bw_jitter_loss_format, start_time, end_time, ubuf, nbuf, sp->jitter, @@ -1055,6 +1050,8 @@ iperf_new_stream(struct iperf_test *testp) sp->result->bytes_received_this_interval = 0; sp->result->bytes_sent_this_interval = 0; + // XXX: This sets the starting time of the test. + // It needs to be set when the test starts, not when the stream is created. gettimeofday(&sp->result->start_time, NULL); sp->settings->state = STREAM_BEGIN; @@ -1117,24 +1114,10 @@ iperf_client_end(struct iperf_test *test) printf("Test Complete. Summary Results:\n"); /* show final summary */ - test->stats_callback(test); + // XXX: Moved stats_callback to end of iperf_send to log correct stream end_time + // test->stats_callback(test); test->reporter_callback(test); - /* Requesting for result from Server - * - * This still needs to be implemented. It looks like the last - * intern worked on it, but it needs to be finished. - */ - - // XXX: Need to implement getting results from server - test->state = RESULT_REQUEST; - //receive_result_from_server(test); /* XXX: currently broken! */ - //result_string = test->reporter_callback(test); - //printf("Summary results as measured by the server: \n"); - //puts(result_string); - - //printf("Done getting/printing results. \n"); - /* Deleting all streams - CAN CHANGE FREE_STREAM FN */ for (sp = test->streams; sp; sp = np) { close(sp->socket); diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index 2698110..f504005 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -70,7 +70,6 @@ iperf_server_listen(struct iperf_test *test) */ // XXX: This code needs to be moved to after parameter exhange - // XXX: Last thing I was working on if (test->protocol == Ptcp) { if (test->default_settings->socket_bufsize > 0) { unit_snprintf(ubuf, UNIT_LEN, (double) x, 'A'); @@ -172,6 +171,7 @@ iperf_handle_message_server(struct iperf_test *test) perror("write DISPLAY_RESULTS"); exit(1); } + test->stats_callback(test); test->reporter_callback(test); break; case IPERF_DONE: @@ -192,8 +192,6 @@ void iperf_test_reset(struct iperf_test *test) { struct iperf_stream *sp, *np; - struct iperf_settings *settings; - int listener; close(test->ctrl_sck); @@ -203,19 +201,30 @@ iperf_test_reset(struct iperf_test *test) iperf_free_stream(sp); } - /* Clear memory and reset defaults */ - memset(test->default_settings, 0, sizeof(struct iperf_settings)); - settings = test->default_settings; - listener = test->listener; - memset(test, 0, sizeof(struct iperf_test)); + test->streams = NULL; + test->role = 's'; - test->default_settings = settings; - iperf_defaults(test); - test->listener = listener; + test->protocol = Ptcp; + test->duration = DURATION; + test->state = 0; + test->server_hostname = NULL; + + test->ctrl_sck = -1; + test->prot_listener = 0; + + test->reverse = 0; + // test->no_delay = 0 (Do we need this reset between tests?) + FD_ZERO(&test->read_set); FD_ZERO(&test->write_set); FD_SET(test->listener, &test->read_set); - test->max_fd = (test->listener > test->max_fd) ? test->listener : test->max_fd; + test->max_fd = test->listener; + + test->num_streams = 1; + test->default_settings->socket_bufsize = 0; + test->default_settings->blksize = DEFAULT_TCP_BLKSIZE; + test->default_settings->rate = RATE; /* UDP only */ + memset(test->default_settings->cookie, 0, COOKIE_SIZE); } int diff --git a/src/tcp_window_size.c b/src/tcp_window_size.c index b019afd..c8c4ca5 100644 --- a/src/tcp_window_size.c +++ b/src/tcp_window_size.c @@ -94,7 +94,7 @@ set_tcp_windowsize(int sock, int bufsize, int dir) if (rc < 0) return rc; } else { - printf("Using default TCP buffer size and assuming OS will do autotuning \n"); + printf(" Using default TCP buffer size and assuming OS will do autotuning\n"); } return 0;