1
1

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

Этот коммит содержится в:
Brian Tierney 2009-11-10 05:21:17 +00:00
родитель e99faeae86
Коммит 5083c489af
5 изменённых файлов: 68 добавлений и 67 удалений

Просмотреть файл

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

Просмотреть файл

@ -691,7 +691,7 @@ iperf_reporter_callback(struct iperf_test * test)
unit_snprintf(ubuf, UNIT_LEN, (double) bytes, 'A'); unit_snprintf(ubuf, UNIT_LEN, (double) bytes, 'A');
unit_snprintf(nbuf, UNIT_LEN, (double) bytes / end_time, test->default_settings->unit_format); 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) if (test->protocol == Ptcp)
{ {
@ -840,36 +840,6 @@ iperf_add_stream(struct iperf_test * test, struct iperf_stream * sp)
return 0; 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 void
@ -889,7 +859,6 @@ iperf_run_client(struct iperf_test * test)
char *prot = NULL; char *prot = NULL;
int64_t delayus, adjustus, dtargus; int64_t delayus, adjustus, dtargus;
struct timeval tv; struct timeval tv;
int ret = 0;
struct sigaction sact; struct sigaction sact;
printf("in iperf_run_client \n"); 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 */ /* send data till the timer expires or bytes sent */
while (!all_data_sent(test) && !timer->expired(timer)) 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; sp = test->streams;
for (i = 0; i < test->num_streams; i++) for (i = 0; i < test->num_streams; i++)
{ {

Просмотреть файл

@ -76,20 +76,6 @@ void *iperf_stats_callback(struct iperf_test * test);
char *iperf_reporter_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 * iperf_run_client -- Runs the client portion of a test
* *

Просмотреть файл

@ -122,6 +122,8 @@ iperf_run_server(struct iperf_test * test)
{ {
struct timeval tv; struct timeval tv;
struct iperf_stream *np; struct iperf_stream *np;
struct timer *stats_interval, *reporter_interval;
char *result_string = NULL;
int j = 0, result = 0, message = 0; int j = 0, result = 0, message = 0;
int nfd = 0; int nfd = 0;
@ -145,6 +147,11 @@ iperf_run_server(struct iperf_test * test)
test->num_streams = 0; test->num_streams = 0;
test->default_settings->state = TEST_RUNNING; 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"); printf("iperf_run_server: Waiting for client connect.... \n");
while (test->default_settings->state != TEST_END) 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 if (FD_ISSET(j, &temp_set)) */
} /* end for (j=0;...) */ } /* end for (j=0;...) */
} /* end else (result>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 */ } /* end while */
done: done:
printf("Test Complete. \n\n"); printf("Test Complete. \n\n");
/* reset cookie when client is finished */ /* reset cookie when client is finished */
memset(test->streams->settings->cookie, '\0', COOKIE_SIZE); memset(test->streams->settings->cookie, '\0', COOKIE_SIZE);
return; return;
@ -290,7 +311,7 @@ handle_message(struct iperf_test * test, int message, struct iperf_stream * sp)
do do
{ {
tp2 = tp1; tp2 = tp1;
printf(" closing socket: %d \n", tp2->socket); //printf(" closing socket: %d \n", tp2->socket);
close(tp2->socket); close(tp2->socket);
FD_CLR(tp2->socket, &test->read_set); FD_CLR(tp2->socket, &test->read_set);
tp1 = tp2->next; /* get next pointer before freeing */ 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); 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;
}

Просмотреть файл

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