Updated the client code to behave like the state machine for TEST_START
Этот коммит содержится в:
родитель
e088d2d305
Коммит
aebbe3a08f
10
src/iperf.h
10
src/iperf.h
@ -136,6 +136,16 @@ struct iperf_test
|
||||
int reporter_fd; /* file descriptor for reporter */
|
||||
int num_streams; /* total streams in the test (-P) */
|
||||
int tcp_info; /* display getsockopt(TCP_INFO) results */
|
||||
|
||||
/* iperf error reporting
|
||||
* - errtype: (0,1,2)
|
||||
* 0: use perror(errno)
|
||||
* 1: use herror(errno)
|
||||
* 2: use ierror(errno)
|
||||
*/
|
||||
//int errtype;
|
||||
//int errno;
|
||||
|
||||
struct iperf_stream *streams; /* pointer to list of struct stream */
|
||||
struct iperf_settings *default_settings;
|
||||
};
|
||||
|
@ -337,7 +337,6 @@ iperf_init_test(struct iperf_test * test)
|
||||
struct iperf_stream *sp;
|
||||
int i, s = 0;
|
||||
|
||||
//printf("in iperf_init_test \n");
|
||||
if (test->role == 's')
|
||||
{ /* server */
|
||||
if (test->protocol == Pudp)
|
||||
@ -383,15 +382,15 @@ iperf_init_test(struct iperf_test * test)
|
||||
}
|
||||
printf("-----------------------------------------------------------\n");
|
||||
|
||||
} else if (test->role == 'c')
|
||||
{ /* Client */
|
||||
}
|
||||
/* This code is being removed. Commented out until removal
|
||||
else if (test->role == 'c')
|
||||
{ // Client
|
||||
FD_ZERO(&test->write_set);
|
||||
FD_SET(s, &test->write_set);
|
||||
|
||||
/*
|
||||
* XXX: I think we need to create a TCP control socket here too for
|
||||
* UDP mode -blt
|
||||
*/
|
||||
// XXX: I think we need to create a TCP control socket here too for
|
||||
// UDP mode -blt
|
||||
for (i = 0; i < test->num_streams; i++)
|
||||
{
|
||||
s = netdial(test->protocol, test->server_hostname, test->server_port);
|
||||
@ -408,9 +407,40 @@ iperf_init_test(struct iperf_test * test)
|
||||
iperf_init_stream(sp, test);
|
||||
iperf_add_stream(test, sp);
|
||||
|
||||
connect_msg(sp); /* print connection established message */
|
||||
connect_msg(sp); // print connection established message
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* iperf_connect -- client to server connection function */
|
||||
int
|
||||
iperf_connect(struct iperf_test *test)
|
||||
{
|
||||
struct iperf_stream *sp;
|
||||
int i, s = 0;
|
||||
|
||||
/* For Select: Set the test->write_set select set to zero, then set the s fd */
|
||||
FD_ZERO(&test->write_set);
|
||||
|
||||
for (i = 0; i < test->num_streams; i++) {
|
||||
s = netdial(test->protocol, test->server_hostname, test->server_port);
|
||||
if (s < 0) {
|
||||
fprintf(stderr, "error: netdial failed\n");
|
||||
exit(1);
|
||||
}
|
||||
FD_SET(s, &test->write_set);
|
||||
test->max_fd = (test->max_fd < s) ? s : test->max_fd;
|
||||
|
||||
sp = test->new_stream(test);
|
||||
sp->socket = s;
|
||||
iperf_init_stream(sp, test);
|
||||
iperf_add_stream(test, sp);
|
||||
|
||||
connect_msg(sp);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
@ -419,6 +449,9 @@ iperf_free_test(struct iperf_test * test)
|
||||
{
|
||||
free(test->default_settings);
|
||||
|
||||
// This funciton needs to be updated to free and close streams
|
||||
// Currently it just sets the pointer to the streams list to NULL...
|
||||
|
||||
close(test->listener_sock_tcp);
|
||||
close(test->listener_sock_udp);
|
||||
|
||||
@ -835,6 +868,11 @@ iperf_run_client(struct iperf_test * test)
|
||||
struct timeval tv;
|
||||
struct sigaction sact;
|
||||
|
||||
if (iperf_connect(test) < 0) {
|
||||
// set error and return
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (iperf_exchange_parameters(test) < 0)
|
||||
{
|
||||
return -1;
|
||||
|
@ -140,7 +140,7 @@ void print_tcpinfo(struct iperf_interval_results *);
|
||||
void build_tcpinfo_message(struct iperf_interval_results *r, char *message);
|
||||
void safe_strcat(char *s1, char *s2);
|
||||
char * print_interval_results(struct iperf_test * test, struct iperf_stream *sp, char *m);
|
||||
|
||||
int iperf_connect(struct iperf_test *);
|
||||
|
||||
|
||||
#endif /* IPERF_API_H */
|
||||
|
17
src/main.c
17
src/main.c
@ -28,6 +28,7 @@
|
||||
#include "units.h"
|
||||
#include "locale.h"
|
||||
|
||||
|
||||
int iperf_run(struct iperf_test * test);
|
||||
|
||||
/**************************************************************************/
|
||||
@ -53,10 +54,15 @@ static struct option longopts[] =
|
||||
{"verbose", no_argument, NULL, 'V'},
|
||||
{"debug", no_argument, NULL, 'd'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"daemon", no_argument, NULL, 'D'},
|
||||
{"format", required_argument, NULL, 'f'},
|
||||
|
||||
/* The following ifdef needs to be split up. linux-congestion is not necessarily supported
|
||||
* by systems that support tos.
|
||||
*/
|
||||
#ifdef ADD_WHEN_SUPPORTED
|
||||
{"tos", required_argument, NULL, 'S'},
|
||||
{"linux-congestion", required_argument, NULL, 'Z'},
|
||||
{"daemon", no_argument, NULL, 'D'},
|
||||
#endif
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
@ -71,6 +77,11 @@ main(int argc, char **argv)
|
||||
struct iperf_test *test;
|
||||
int port = PORT;
|
||||
|
||||
// The following lines need to be removed and moved to somewhere else!!!
|
||||
const char *usage_long1 = "this is usage_long1";
|
||||
const char *usage_long2 = "this is usage_long2";
|
||||
|
||||
|
||||
#ifdef TEST_PROC_AFFINITY
|
||||
/* didnt seem to work.... */
|
||||
/*
|
||||
@ -230,8 +241,8 @@ main(int argc, char **argv)
|
||||
|
||||
/* exit until this is done.... */
|
||||
if (test->protocol == Pudp) {
|
||||
printf("UDP mode not yet supported. Exiting. \n");
|
||||
exit(0);
|
||||
printf("UDP mode not yet supported. Exiting. \n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//printf("in main: calling iperf_init_test \n");
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user