2014-05-19 22:33:38 +00:00
|
|
|
#include "iperf_config.h"
|
|
|
|
|
2013-03-12 05:03:36 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
2014-05-19 17:15:36 +00:00
|
|
|
#ifdef HAVE_STDINT_H
|
2013-03-12 05:03:36 +00:00
|
|
|
#include <stdint.h>
|
2014-05-19 17:15:36 +00:00
|
|
|
#endif
|
2013-03-12 05:03:36 +00:00
|
|
|
|
|
|
|
#include <iperf_api.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main( int argc, char** argv )
|
|
|
|
{
|
|
|
|
char* argv0;
|
|
|
|
char* host;
|
|
|
|
int port;
|
|
|
|
struct iperf_test *test;
|
|
|
|
|
|
|
|
argv0 = strrchr( argv[0], '/' );
|
|
|
|
if ( argv0 != (char*) 0 )
|
|
|
|
++argv0;
|
|
|
|
else
|
|
|
|
argv0 = argv[0];
|
|
|
|
|
|
|
|
if ( argc != 3 ) {
|
|
|
|
fprintf( stderr, "usage: %s [host] [port]\n", argv0 );
|
|
|
|
exit( EXIT_FAILURE );
|
|
|
|
}
|
|
|
|
host = argv[1];
|
|
|
|
port = atoi( argv[2] );
|
|
|
|
|
|
|
|
test = iperf_new_test();
|
|
|
|
if ( test == NULL ) {
|
|
|
|
fprintf( stderr, "%s: failed to create test\n", argv0 );
|
|
|
|
exit( EXIT_FAILURE );
|
|
|
|
}
|
|
|
|
iperf_defaults( test );
|
2013-08-29 18:38:20 +00:00
|
|
|
iperf_set_verbose( test, 1 );
|
2013-04-09 18:42:30 +00:00
|
|
|
|
2013-03-12 05:03:36 +00:00
|
|
|
iperf_set_test_role( test, 'c' );
|
|
|
|
iperf_set_test_server_hostname( test, host );
|
|
|
|
iperf_set_test_server_port( test, port );
|
2013-08-29 18:38:20 +00:00
|
|
|
/* iperf_set_test_reverse( test, 1 ); */
|
|
|
|
iperf_set_test_omit( test, 3 );
|
|
|
|
iperf_set_test_duration( test, 5 );
|
|
|
|
iperf_set_test_reporter_interval( test, 1 );
|
|
|
|
iperf_set_test_stats_interval( test, 1 );
|
2014-04-07 21:12:47 +00:00
|
|
|
/* iperf_set_test_json_output( test, 1 ); */
|
2013-03-12 05:03:36 +00:00
|
|
|
|
|
|
|
if ( iperf_run_client( test ) < 0 ) {
|
|
|
|
fprintf( stderr, "%s: error - %s\n", argv0, iperf_strerror( i_errno ) );
|
|
|
|
exit( EXIT_FAILURE );
|
|
|
|
}
|
|
|
|
|
2014-04-07 21:12:47 +00:00
|
|
|
if (iperf_get_test_json_output_string(test)) {
|
|
|
|
fprintf(iperf_get_test_outfile(test), "%zd bytes of JSON emitted\n",
|
|
|
|
strlen(iperf_get_test_json_output_string(test)));
|
|
|
|
}
|
|
|
|
|
2013-03-12 05:03:36 +00:00
|
|
|
iperf_free_test( test );
|
|
|
|
exit( EXIT_SUCCESS );
|
|
|
|
}
|