2009-11-02 22:43:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2009, The Regents of the University of California, through
|
|
|
|
* Lawrence Berkeley National Laboratory (subject to receipt of any required
|
|
|
|
* approvals from the U.S. Dept. of Energy). All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* iperf_server_api.c: Functions to be used by an iperf server
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sched.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
|
|
#include "iperf.h"
|
|
|
|
#include "iperf_server_api.h"
|
|
|
|
#include "iperf_api.h"
|
|
|
|
#include "iperf_udp.h"
|
|
|
|
#include "iperf_tcp.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "net.h"
|
|
|
|
#include "units.h"
|
|
|
|
#include "tcp_window_size.h"
|
|
|
|
#include "uuid.h"
|
|
|
|
#include "locale.h"
|
|
|
|
|
2010-06-23 19:13:37 +00:00
|
|
|
jmp_buf env;
|
2009-11-02 22:43:19 +00:00
|
|
|
|
2010-06-18 21:08:50 +00:00
|
|
|
int
|
|
|
|
iperf_server_listen(struct iperf_test *test)
|
2009-11-02 22:43:19 +00:00
|
|
|
{
|
2010-06-18 21:08:50 +00:00
|
|
|
char ubuf[UNIT_LEN];
|
|
|
|
int x;
|
|
|
|
|
2010-06-30 22:09:45 +00:00
|
|
|
if((test->listener_tcp = netannounce(Ptcp, NULL, test->server_port)) < 0) {
|
2010-06-18 21:08:50 +00:00
|
|
|
// Needs to set some sort of error number/message
|
2010-06-30 22:09:45 +00:00
|
|
|
perror("netannounce test->listener_tcp");
|
2010-06-18 21:08:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2009-11-02 22:43:19 +00:00
|
|
|
|
2010-06-18 21:08:50 +00:00
|
|
|
printf("-----------------------------------------------------------\n");
|
|
|
|
printf("Server listening on %d\n", test->server_port);
|
|
|
|
|
|
|
|
// This needs to be changed to reflect if client has different window size
|
|
|
|
// make sure we got what we asked for
|
2010-06-21 15:08:47 +00:00
|
|
|
/* XXX: This needs to be moved to the stream listener
|
2010-06-18 21:08:50 +00:00
|
|
|
if ((x = get_tcp_windowsize(test->listener_sock_tcp, SO_RCVBUF)) < 0) {
|
|
|
|
// Needs to set some sort of error number/message
|
|
|
|
perror("SO_RCVBUF");
|
|
|
|
return -1;
|
|
|
|
}
|
2010-06-21 15:08:47 +00:00
|
|
|
*/
|
2010-06-18 21:08:50 +00:00
|
|
|
|
2010-06-21 15:08:47 +00:00
|
|
|
// XXX: This code needs to be moved to after parameter exhange
|
2010-06-18 21:08:50 +00:00
|
|
|
if (test->protocol == Ptcp) {
|
|
|
|
if (test->default_settings->socket_bufsize > 0) {
|
|
|
|
unit_snprintf(ubuf, UNIT_LEN, (double) x, 'A');
|
|
|
|
printf("TCP window size: %s\n", ubuf);
|
|
|
|
} else {
|
|
|
|
printf("Using TCP Autotuning\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("-----------------------------------------------------------\n");
|
2009-11-06 02:19:20 +00:00
|
|
|
|
2009-11-02 22:43:19 +00:00
|
|
|
FD_ZERO(&test->read_set);
|
2010-06-30 15:58:16 +00:00
|
|
|
FD_ZERO(&test->write_set);
|
2010-06-30 22:09:45 +00:00
|
|
|
FD_SET(test->listener_tcp, &test->read_set);
|
|
|
|
test->max_fd = (test->listener_tcp > test->max_fd) ? test->listener_tcp : test->max_fd;
|
2010-06-18 21:08:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
iperf_accept(struct iperf_test *test)
|
|
|
|
{
|
|
|
|
int s;
|
2010-06-23 19:13:37 +00:00
|
|
|
int rbuf = ACCESS_DENIED;
|
2010-06-18 21:08:50 +00:00
|
|
|
char ipl[512], ipr[512];
|
2010-06-30 22:09:45 +00:00
|
|
|
char cookie[COOKIE_SIZE];
|
2010-06-18 21:08:50 +00:00
|
|
|
socklen_t len;
|
|
|
|
struct sockaddr_in addr;
|
2010-06-23 19:13:37 +00:00
|
|
|
struct sockaddr_in temp1, temp2;
|
2010-06-30 22:09:45 +00:00
|
|
|
struct iperf_stream *sp;
|
|
|
|
static int streams_accepted;
|
2010-07-06 23:12:54 +00:00
|
|
|
|
|
|
|
len = sizeof(addr);
|
2010-06-30 22:09:45 +00:00
|
|
|
if ((s = accept(test->listener_tcp, (struct sockaddr *) &addr, &len)) < 0) {
|
|
|
|
perror("accept");
|
|
|
|
return -1;
|
|
|
|
}
|
2010-06-18 21:08:50 +00:00
|
|
|
|
2010-06-23 19:13:37 +00:00
|
|
|
if (test->ctrl_sck == -1) {
|
2010-06-30 22:09:45 +00:00
|
|
|
/* Server free, accept new client */
|
|
|
|
if (Nread(s, test->default_settings->cookie, COOKIE_SIZE, Ptcp) < 0) {
|
|
|
|
perror("Nread COOKIE\n");
|
2010-06-18 21:08:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2010-06-30 22:09:45 +00:00
|
|
|
|
2010-06-23 19:13:37 +00:00
|
|
|
FD_SET(s, &test->read_set);
|
|
|
|
FD_SET(s, &test->write_set);
|
|
|
|
test->max_fd = (s > test->max_fd) ? s : test->max_fd;
|
|
|
|
test->ctrl_sck = s;
|
2010-06-30 22:09:45 +00:00
|
|
|
streams_accepted = 0;
|
2010-06-18 21:08:50 +00:00
|
|
|
|
2010-06-23 19:13:37 +00:00
|
|
|
len = sizeof(struct sockaddr_in);
|
|
|
|
if (getsockname(s, (struct sockaddr *) &temp1, &len) < 0)
|
|
|
|
perror("getsockname");
|
|
|
|
if (getpeername(s, (struct sockaddr *) &temp2, &len) < 0)
|
|
|
|
perror("getpeername");
|
|
|
|
|
|
|
|
inet_ntop(AF_INET, (void *) &temp1.sin_addr, ipl, sizeof(ipl));
|
|
|
|
inet_ntop(AF_INET, (void *) &temp2.sin_addr, ipr, sizeof(ipr));
|
|
|
|
printf(report_peer, s, ipl, ntohs(temp1.sin_port), ipr, ntohs(temp2.sin_port));
|
|
|
|
|
2010-06-30 22:09:45 +00:00
|
|
|
test->state = PARAM_EXCHANGE;
|
|
|
|
if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
|
|
|
|
perror("Nwrite PARAM_EXCHANGE\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
iperf_exchange_parameters(test);
|
2010-06-18 21:08:50 +00:00
|
|
|
} else {
|
2010-06-30 22:09:45 +00:00
|
|
|
if (Nread(s, cookie, COOKIE_SIZE, Ptcp) < 0) {
|
|
|
|
perror("Nread COOKIE\n");
|
2010-06-23 19:13:37 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2010-06-30 22:09:45 +00:00
|
|
|
if ((strcmp(test->default_settings->cookie, cookie) == 0) && (test->state == CREATE_STREAMS)) {
|
|
|
|
sp = test->new_stream(test);
|
|
|
|
sp->socket = s;
|
|
|
|
iperf_init_stream(sp, test);
|
|
|
|
iperf_add_stream(test, sp);
|
|
|
|
FD_SET(s, &test->read_set);
|
|
|
|
FD_SET(s, &test->write_set);
|
|
|
|
test->max_fd = (s > test->max_fd) ? s : test->max_fd;
|
|
|
|
connect_msg(sp);
|
|
|
|
|
|
|
|
++streams_accepted;
|
|
|
|
if (streams_accepted == test->num_streams) {
|
|
|
|
test->state = TEST_START;
|
|
|
|
if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
|
|
|
|
perror("Nwrite TEST_START\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2010-07-01 00:01:57 +00:00
|
|
|
if (Nwrite(s, &rbuf, sizeof(int), Ptcp) < 0) {
|
|
|
|
perror("Nwrite ACCESS_DENIED");
|
2010-06-30 22:09:45 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
close(s);
|
2010-06-23 19:13:37 +00:00
|
|
|
}
|
2009-11-10 04:41:42 +00:00
|
|
|
}
|
2010-06-30 22:09:45 +00:00
|
|
|
|
|
|
|
return 0;
|
2010-06-18 21:08:50 +00:00
|
|
|
}
|
|
|
|
|
2010-07-06 23:12:54 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
iperf_accept_tcp_stream(struct iperf_test *test)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
int rbuf = ACCESS_DENIED;
|
|
|
|
char cookie[COOKIE_SIZE];
|
|
|
|
socklen_t len;
|
|
|
|
struct sockaddr_in addr;
|
|
|
|
struct iperf_stream *sp;
|
|
|
|
|
|
|
|
len = sizeof(addr);
|
|
|
|
if ((s = accept(test->listener_tcp, (struct sockaddr *) &addr, &len)) < 0) {
|
|
|
|
perror("accept tcp stream");
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Nread(s, cookie, COOKIE_SIZE, Ptcp) < 0) {
|
|
|
|
perror("Nread cookie");
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(test->default_settings->cookie, cookie) == 0) {
|
|
|
|
// XXX: CANNOT USE iperf_tcp_accept since stream is alread accepted at this point. New model needed!
|
|
|
|
sp = test->new_stream(test);
|
|
|
|
sp->socket = s;
|
|
|
|
iperf_init_stream(sp, test);
|
|
|
|
iperf_add_stream(test, sp);
|
|
|
|
FD_SET(s, &test->read_set);
|
|
|
|
FD_SET(s, &test->write_set);
|
|
|
|
test->max_fd = (s > test->max_fd) ? s : test->max_fd;
|
|
|
|
test->streams_accepted++;
|
|
|
|
connect_msg(sp);
|
|
|
|
} else {
|
|
|
|
if (Nwrite(s, &rbuf, sizeof(char), Ptcp) < 0) {
|
|
|
|
perror("Nwrite ACCESS_DENIED");
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
close(s);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
iperf_accept_udp_stream(struct iperf_test *test)
|
|
|
|
{
|
|
|
|
// do nothing for now
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2010-06-18 21:08:50 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
int
|
2010-06-23 19:13:37 +00:00
|
|
|
iperf_handle_message_server(struct iperf_test *test)
|
2010-06-18 21:08:50 +00:00
|
|
|
{
|
2010-07-06 23:12:54 +00:00
|
|
|
int rval;
|
2010-06-30 15:58:16 +00:00
|
|
|
struct iperf_stream *sp;
|
|
|
|
|
2010-07-06 23:12:54 +00:00
|
|
|
if ((rval = read(test->ctrl_sck, &test->state, sizeof(char))) <= 0) {
|
|
|
|
if (rval == 0) {
|
|
|
|
fprintf(stderr, "The client has unexpectedly closed the connection.\n");
|
|
|
|
test->state = IPERF_DONE;
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
perror("read ctrl_sck");
|
|
|
|
return -1;
|
|
|
|
}
|
2010-06-18 21:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(test->state) {
|
2010-06-21 15:08:47 +00:00
|
|
|
case TEST_START:
|
|
|
|
break;
|
2010-06-23 19:13:37 +00:00
|
|
|
case TEST_RUNNING:
|
|
|
|
break;
|
|
|
|
case TEST_END:
|
2010-06-30 15:58:16 +00:00
|
|
|
for (sp = test->streams; sp; sp = sp->next) {
|
|
|
|
FD_CLR(sp->socket, &test->read_set);
|
|
|
|
FD_CLR(sp->socket, &test->write_set);
|
|
|
|
close(sp->socket);
|
|
|
|
}
|
2010-06-29 22:02:30 +00:00
|
|
|
test->state = EXCHANGE_RESULTS;
|
2010-07-01 00:01:57 +00:00
|
|
|
if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
|
|
|
|
perror("Nwrite EXCHANGE_RESULTS");
|
2010-06-29 22:02:30 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
iperf_exchange_results(test);
|
2010-06-23 20:28:32 +00:00
|
|
|
test->state = DISPLAY_RESULTS;
|
2010-07-01 00:01:57 +00:00
|
|
|
if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
|
|
|
|
perror("Nwrite DISPLAY_RESULTS");
|
2010-06-23 19:13:37 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2010-06-30 19:57:17 +00:00
|
|
|
test->stats_callback(test);
|
2010-06-29 22:02:30 +00:00
|
|
|
test->reporter_callback(test);
|
2010-06-23 19:13:37 +00:00
|
|
|
break;
|
2010-06-23 20:28:32 +00:00
|
|
|
case IPERF_DONE:
|
|
|
|
break;
|
2010-06-23 19:13:37 +00:00
|
|
|
case CLIENT_TERMINATE:
|
|
|
|
fprintf(stderr, "The client has terminated. Exiting...\n");
|
2010-06-21 15:08:47 +00:00
|
|
|
exit(1);
|
|
|
|
default:
|
|
|
|
// XXX: This needs to be replaced by actual error handling
|
2010-07-06 23:12:54 +00:00
|
|
|
fprintf(stderr, "Unrecognized state: %d\n", test->state);
|
2010-06-21 15:08:47 +00:00
|
|
|
return -1;
|
2010-06-18 21:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-11-02 22:43:19 +00:00
|
|
|
|
2010-06-30 15:58:16 +00:00
|
|
|
void
|
|
|
|
iperf_test_reset(struct iperf_test *test)
|
|
|
|
{
|
|
|
|
struct iperf_stream *sp, *np;
|
|
|
|
|
|
|
|
close(test->ctrl_sck);
|
|
|
|
|
|
|
|
/* Free streams */
|
|
|
|
for (sp = test->streams; sp; sp = np) {
|
|
|
|
np = sp->next;
|
|
|
|
iperf_free_stream(sp);
|
|
|
|
}
|
|
|
|
|
2010-06-30 19:57:17 +00:00
|
|
|
test->streams = NULL;
|
|
|
|
|
2010-06-30 15:58:16 +00:00
|
|
|
test->role = 's';
|
2010-06-30 19:57:17 +00:00
|
|
|
test->protocol = Ptcp;
|
|
|
|
test->duration = DURATION;
|
|
|
|
test->state = 0;
|
|
|
|
test->server_hostname = NULL;
|
|
|
|
|
|
|
|
test->ctrl_sck = -1;
|
|
|
|
test->prot_listener = 0;
|
|
|
|
|
|
|
|
test->reverse = 0;
|
2010-07-06 23:12:54 +00:00
|
|
|
test->no_delay = 0;
|
2010-06-30 19:57:17 +00:00
|
|
|
|
2010-06-30 15:58:16 +00:00
|
|
|
FD_ZERO(&test->read_set);
|
|
|
|
FD_ZERO(&test->write_set);
|
2010-06-30 22:09:45 +00:00
|
|
|
FD_SET(test->listener_tcp, &test->read_set);
|
|
|
|
test->max_fd = test->listener_tcp;
|
2010-06-30 19:57:17 +00:00
|
|
|
|
|
|
|
test->num_streams = 1;
|
2010-07-06 23:12:54 +00:00
|
|
|
test->streams_accepted = 0;
|
2010-06-30 19:57:17 +00:00
|
|
|
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);
|
2010-06-30 15:58:16 +00:00
|
|
|
}
|
|
|
|
|
2010-06-23 21:34:07 +00:00
|
|
|
int
|
2010-06-18 21:08:50 +00:00
|
|
|
iperf_run_server(struct iperf_test *test)
|
|
|
|
{
|
2010-06-23 21:34:07 +00:00
|
|
|
int result;
|
2010-06-30 15:58:16 +00:00
|
|
|
int streams_accepted;
|
|
|
|
fd_set temp_read_set, temp_write_set;
|
2010-06-23 21:34:07 +00:00
|
|
|
struct timeval tv;
|
2010-06-18 21:08:50 +00:00
|
|
|
|
|
|
|
// Open socket and listen
|
|
|
|
if (iperf_server_listen(test) < 0) {
|
2010-07-06 23:12:54 +00:00
|
|
|
// XXX: This needs to be replaced by more formal error handling
|
2010-06-18 21:08:50 +00:00
|
|
|
fprintf(stderr, "An error occurred. Exiting.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2009-11-02 22:43:19 +00:00
|
|
|
|
2010-06-23 19:13:37 +00:00
|
|
|
signal(SIGINT, sig_handler);
|
|
|
|
if (setjmp(env)) {
|
|
|
|
fprintf(stderr, "Interrupt received. Exiting...\n");
|
|
|
|
test->state = SERVER_TERMINATE;
|
|
|
|
if (test->ctrl_sck >= 0) {
|
2010-07-01 00:01:57 +00:00
|
|
|
if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
|
2010-06-23 19:13:37 +00:00
|
|
|
fprintf(stderr, "Unable to send SERVER_TERMINATE message to client\n");
|
|
|
|
}
|
|
|
|
}
|
2010-07-01 21:21:04 +00:00
|
|
|
return 0;
|
2010-06-23 19:13:37 +00:00
|
|
|
}
|
|
|
|
|
2010-07-01 21:21:04 +00:00
|
|
|
for ( ; ; ) {
|
2009-11-02 22:43:19 +00:00
|
|
|
|
2010-06-30 22:09:45 +00:00
|
|
|
test->state = IPERF_START;
|
2010-06-18 21:08:50 +00:00
|
|
|
|
2010-06-30 22:09:45 +00:00
|
|
|
while (test->state != IPERF_DONE) {
|
2010-06-18 21:08:50 +00:00
|
|
|
|
2010-06-30 22:09:45 +00:00
|
|
|
memcpy(&temp_read_set, &test->read_set, sizeof(fd_set));
|
|
|
|
memcpy(&temp_write_set, &test->write_set, sizeof(fd_set));
|
|
|
|
tv.tv_sec = 15;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
|
|
|
|
result = select(test->max_fd + 1, &temp_read_set, &temp_write_set, NULL, &tv);
|
|
|
|
if (result < 0 && errno != EINTR) {
|
|
|
|
// Change the way this handles errors
|
|
|
|
perror("select");
|
|
|
|
exit(1);
|
|
|
|
} else if (result > 0) {
|
|
|
|
if (FD_ISSET(test->listener_tcp, &temp_read_set)) {
|
2010-07-06 23:12:54 +00:00
|
|
|
if (test->state != CREATE_STREAMS) {
|
|
|
|
if (iperf_accept(test) < 0) {
|
|
|
|
fprintf(stderr, "iperf_accept: error accepting control socket. exiting...\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FD_CLR(test->listener_tcp, &temp_read_set);
|
2010-06-30 22:09:45 +00:00
|
|
|
}
|
2010-06-18 21:08:50 +00:00
|
|
|
}
|
2010-06-30 22:09:45 +00:00
|
|
|
if (FD_ISSET(test->ctrl_sck, &temp_read_set)) {
|
|
|
|
iperf_handle_message_server(test);
|
|
|
|
FD_CLR(test->ctrl_sck, &temp_read_set);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test->state == CREATE_STREAMS) {
|
2010-07-06 23:12:54 +00:00
|
|
|
if (test->protocol == Ptcp) {
|
|
|
|
if (FD_ISSET(test->listener_tcp, &temp_read_set)) {
|
|
|
|
if (iperf_accept_tcp_stream(test) < 0) {
|
|
|
|
fprintf(stderr, "iperf_accept_tcp_stream: an error occurred.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FD_CLR(test->listener_tcp, &temp_read_set);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (FD_ISSET(test->listener_udp, &temp_read_set)) {
|
|
|
|
if (iperf_accept_udp_stream(test) < 0) {
|
|
|
|
fprintf(stderr, "iperf_accept_udp_stream: an error occurred.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FD_CLR(test->listener_udp, &temp_read_set);
|
|
|
|
}
|
2010-06-30 22:09:45 +00:00
|
|
|
}
|
2010-07-06 23:12:54 +00:00
|
|
|
if (test->streams_accepted == test->num_streams) {
|
2010-06-30 22:09:45 +00:00
|
|
|
test->state = TEST_START;
|
2010-07-06 23:12:54 +00:00
|
|
|
if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
|
|
|
|
perror("Nwrite TEST_START");
|
2010-06-30 22:09:45 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2010-06-23 19:13:37 +00:00
|
|
|
}
|
2010-06-18 21:08:50 +00:00
|
|
|
}
|
2010-06-30 22:09:45 +00:00
|
|
|
|
|
|
|
if (test->reverse) {
|
|
|
|
// Reverse mode. Server sends.
|
|
|
|
iperf_send(test);
|
|
|
|
} else {
|
|
|
|
// Regular mode. Server receives.
|
|
|
|
iperf_recv(test);
|
|
|
|
}
|
2010-06-18 21:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-06 07:25:10 +00:00
|
|
|
|
2010-06-30 22:09:45 +00:00
|
|
|
/* Clean up the last test */
|
|
|
|
iperf_test_reset(test);
|
|
|
|
printf("\n");
|
2010-06-30 15:58:16 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-06-23 21:34:07 +00:00
|
|
|
return 0;
|
2009-11-06 07:25:10 +00:00
|
|
|
}
|
|
|
|
|