more cleanup and bug fixes: TCP mode mostly working. Still bug in using -i on the server

This commit is contained in:
Brian Tierney 2009-11-10 05:21:17 +00:00
parent e99faeae86
commit 5083c489af
5 changed files with 68 additions and 67 deletions

View File

@ -1,24 +1,26 @@
Current list of things to fix/add to iperf 3.0
- finish/fix receive_result_from_server()
- also: should this be called for TCP too, or only UDP (currently its both,
but I think it should be UDP only, or maybe a command line option for TCP
- document and verify the 'state machine'. Is it an error to send messages in the wrong order?
- what is "STREAM_RUNNING" vs "TEST_RUNNING"??
- (-i N) mode on server does not work
- (-i N) mode on server does not work (bus error)
- add sanity checks on -l, -i, -t, -n, and -w options
- separate iperf_api.c into iperf_client.c and iperf_utils.c
- verify placment of all timing calls and total_bytes_sent computations
- break up into client/sever files and TCP/UDP files
- look for 'XXX' in code and address
- add -v (version)
- much better/standard error handling throughout
- better packaging/makefile, README, LICENCE, etc files
- finish/fix receive_result_from_server()
- should this be called for TCP too, or only UDP (currently its both,
but I think it should be UDP only, or maybe a command line option for TCP
- document and verify the 'state machine'. Is it an error to send messages in the wrong order?
- e.g.: what is "STREAM_RUNNING" vs "TEST_RUNNING"??
- cleanup/fix/test UDP mode
- IPV6
- add verbose and debug options
- add human readable vs machine readable output mode
(my idea on this is that "human readable" = compatable with old iperf,
and that "machine readable is all name=value pairs -blt )
- add IPV6
- lots more testing
- look for 'XXX' in code and address
- deamon mode
- add daemon mode (-D)
- see issue tracker for other wish list items

View File

@ -691,7 +691,7 @@ iperf_reporter_callback(struct iperf_test * test)
unit_snprintf(ubuf, UNIT_LEN, (double) bytes, 'A');
unit_snprintf(nbuf, UNIT_LEN, (double) bytes / end_time, test->default_settings->unit_format);
if ((test->role == 'c' && test->num_streams > 1) || (test->role == 's'))
if ((test->role == 'c' || (test->role == 's')) && test->num_streams > 1)
{
if (test->protocol == Ptcp)
{
@ -840,36 +840,6 @@ iperf_add_stream(struct iperf_test * test, struct iperf_stream * sp)
return 0;
}
/**************************************************************************/
/**
* find_stream_by_socket -- finds the stream based on socket ID
*
*returns stream
*
*/
struct iperf_stream *
find_stream_by_socket(struct iperf_test * test, int sock)
{
struct iperf_stream *n;
n = test->streams;
while (1)
{
if (n->socket == sock)
break;
if (n->next == NULL)
break;
n = n->next;
}
return n;
}
/**************************************************************************/
void
@ -889,7 +859,6 @@ iperf_run_client(struct iperf_test * test)
char *prot = NULL;
int64_t delayus, adjustus, dtargus;
struct timeval tv;
int ret = 0;
struct sigaction sact;
printf("in iperf_run_client \n");
@ -945,16 +914,6 @@ iperf_run_client(struct iperf_test * test)
/* send data till the timer expires or bytes sent */
while (!all_data_sent(test) && !timer->expired(timer))
{
#ifdef NEED_THIS /* not sure what this was for, so removed
* -blt */
memcpy(&test->temp_set, &test->write_set, sizeof(test->write_set));
printf("Calling select... \n");
ret = select(test->max_fd + 1, NULL, &test->write_set, NULL, &tv);
if (ret < 0)
continue;
#endif
sp = test->streams;
for (i = 0; i < test->num_streams; i++)
{

View File

@ -76,20 +76,6 @@ void *iperf_stats_callback(struct iperf_test * test);
char *iperf_reporter_callback(struct iperf_test * test);
/**
* find_stream_by_socket -- finds the stream based on socket
*
*returns stream
*
*/
struct iperf_stream *find_stream_by_socket(struct iperf_test * test, int sock);
/**
* iperf_run_server -- Runs the server portion of a test
*
*/
void iperf_run_server(struct iperf_test * test);
/**
* iperf_run_client -- Runs the client portion of a test
*

View File

@ -122,6 +122,8 @@ iperf_run_server(struct iperf_test * test)
{
struct timeval tv;
struct iperf_stream *np;
struct timer *stats_interval, *reporter_interval;
char *result_string = NULL;
int j = 0, result = 0, message = 0;
int nfd = 0;
@ -145,6 +147,11 @@ iperf_run_server(struct iperf_test * test)
test->num_streams = 0;
test->default_settings->state = TEST_RUNNING;
if (test->stats_interval != 0)
stats_interval = new_timer(test->stats_interval, 0);
if (test->reporter_interval != 0)
reporter_interval = new_timer(test->reporter_interval, 0);
printf("iperf_run_server: Waiting for client connect.... \n");
while (test->default_settings->state != TEST_END)
@ -218,10 +225,24 @@ iperf_run_server(struct iperf_test * test)
} /* end if (FD_ISSET(j, &temp_set)) */
} /* end for (j=0;...) */
} /* end else (result>0) */
if ((test->stats_interval != 0) && stats_interval->expired(stats_interval))
{
test->stats_callback(test);
update_timer(stats_interval, test->stats_interval, 0);
}
if ((test->reporter_interval != 0) && reporter_interval->expired(reporter_interval))
{
result_string = test->reporter_callback(test);
//printf("interval expired: printing results: \n");
puts(result_string);
update_timer(reporter_interval, test->reporter_interval, 0);
}
} /* end while */
done:
printf("Test Complete. \n\n");
/* reset cookie when client is finished */
memset(test->streams->settings->cookie, '\0', COOKIE_SIZE);
return;
@ -290,7 +311,7 @@ handle_message(struct iperf_test * test, int message, struct iperf_stream * sp)
do
{
tp2 = tp1;
printf(" closing socket: %d \n", tp2->socket);
//printf(" closing socket: %d \n", tp2->socket);
close(tp2->socket);
FD_CLR(tp2->socket, &test->read_set);
tp1 = tp2->next; /* get next pointer before freeing */
@ -301,3 +322,34 @@ handle_message(struct iperf_test * test, int message, struct iperf_stream * sp)
memset(test->default_settings->cookie, '\0', COOKIE_SIZE);
}
}
/**************************************************************************/
/**
* find_stream_by_socket -- finds the stream based on socket ID
* simple sequential scan: not more effiecient, but should be fine
* for a small number of streams.
*
*returns stream
*
*/
struct iperf_stream *
find_stream_by_socket(struct iperf_test * test, int sock)
{
struct iperf_stream *n;
n = test->streams;
while (1)
{
if (n->socket == sock)
break;
if (n->next == NULL)
break;
n = n->next;
}
return n;
}

View File

@ -2,4 +2,6 @@
int param_received(struct iperf_stream *sp, struct param_exchange * param);
void send_result_to_client(struct iperf_stream * sp);
void iperf_run_server(struct iperf_test * test);
struct iperf_stream *find_stream_by_socket(struct iperf_test * test, int sock);