mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-16 23:15:37 +00:00
lwiperf: make tradeoff client mode work
This commit is contained in:
parent
fb21bc1609
commit
b9b74b2d92
@ -7,11 +7,15 @@
|
|||||||
* @defgroup iperf Iperf server
|
* @defgroup iperf Iperf server
|
||||||
* @ingroup apps
|
* @ingroup apps
|
||||||
*
|
*
|
||||||
* This is a simple performance measuring server to check your bandwith using
|
* This is a simple performance measuring client/server to check your bandwith using
|
||||||
* iPerf2 on a PC as client.
|
* iPerf2 on a PC as server/client.
|
||||||
* It is currently a minimal implementation providing an IPv4 TCP server only.
|
* It is currently a minimal implementation providing an IPv4 TCP client/server only.
|
||||||
*
|
*
|
||||||
* @todo: implement UDP mode and IPv6
|
* @todo:
|
||||||
|
* - implement UDP mode and IPv6
|
||||||
|
* - protect combined sessions handling (via 'related_master_state') against reallocation
|
||||||
|
* (this is a pointer address, currently, so if the same memory is allocated again,
|
||||||
|
* session pairs (tx/rx) can be confused on reallocation)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -116,6 +120,8 @@ typedef struct _lwiperf_state_tcp {
|
|||||||
void *report_arg;
|
void *report_arg;
|
||||||
u8_t poll_count;
|
u8_t poll_count;
|
||||||
u8_t next_num;
|
u8_t next_num;
|
||||||
|
/* 1=start server when client is closed */
|
||||||
|
u8_t client_tradeoff_mode;
|
||||||
u32_t bytes_transferred;
|
u32_t bytes_transferred;
|
||||||
lwiperf_settings_t settings;
|
lwiperf_settings_t settings;
|
||||||
u8_t have_settings_buf;
|
u8_t have_settings_buf;
|
||||||
@ -206,7 +212,6 @@ lwiperf_list_remove(lwiperf_state_base_t *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: unused for now
|
|
||||||
static lwiperf_state_base_t *
|
static lwiperf_state_base_t *
|
||||||
lwiperf_list_find(lwiperf_state_base_t *item)
|
lwiperf_list_find(lwiperf_state_base_t *item)
|
||||||
{
|
{
|
||||||
@ -217,7 +222,7 @@ lwiperf_list_find(lwiperf_state_base_t *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/** Call the report function of an iperf tcp session */
|
/** Call the report function of an iperf tcp session */
|
||||||
static void
|
static void
|
||||||
@ -625,10 +630,14 @@ lwiperf_tcp_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
|
|||||||
tcp_err(conn->conn_pcb, lwiperf_tcp_err);
|
tcp_err(conn->conn_pcb, lwiperf_tcp_err);
|
||||||
|
|
||||||
if (s->specific_remote) {
|
if (s->specific_remote) {
|
||||||
/* this listener belongs to a client, so close it and make the client the master */
|
/* this listener belongs to a client, so make the client the master of the newly created connection */
|
||||||
conn->base.related_master_state = s->base.related_master_state;
|
conn->base.related_master_state = s->base.related_master_state;
|
||||||
s->report_fn = NULL;
|
/* if dual mode or (tradeoff mode AND client is done): close the listener */
|
||||||
lwiperf_tcp_close(s, LWIPERF_TCP_ABORTED_LOCAL);
|
if (!s->client_tradeoff_mode || !lwiperf_list_find(s->base.related_master_state)) {
|
||||||
|
/* prevent report when closing: this is expected */
|
||||||
|
s->report_fn = NULL;
|
||||||
|
lwiperf_tcp_close(s, LWIPERF_TCP_ABORTED_LOCAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lwiperf_list_add(&conn->base);
|
lwiperf_list_add(&conn->base);
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -765,10 +774,8 @@ void* lwiperf_start_tcp_client(const ip_addr_t* remote_addr, u16_t remote_port,
|
|||||||
break;
|
break;
|
||||||
case LWIPERF_TRADEOFF:
|
case LWIPERF_TRADEOFF:
|
||||||
/* Do a bidirectional test individually */
|
/* Do a bidirectional test individually */
|
||||||
return NULL;
|
|
||||||
/* TODO: implement this!
|
|
||||||
settings.flags = htonl(LWIPERF_FLAGS_ANSWER_TEST);
|
settings.flags = htonl(LWIPERF_FLAGS_ANSWER_TEST);
|
||||||
break;*/
|
break;
|
||||||
default:
|
default:
|
||||||
/* invalid argument */
|
/* invalid argument */
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -781,7 +788,7 @@ void* lwiperf_start_tcp_client(const ip_addr_t* remote_addr, u16_t remote_port,
|
|||||||
ret = lwiperf_tx_start_impl(remote_addr, remote_port, &settings, report_fn, report_arg, NULL, &state);
|
ret = lwiperf_tx_start_impl(remote_addr, remote_port, &settings, report_fn, report_arg, NULL, &state);
|
||||||
if (ret == ERR_OK) {
|
if (ret == ERR_OK) {
|
||||||
LWIP_ASSERT("state != NULL", state != NULL);
|
LWIP_ASSERT("state != NULL", state != NULL);
|
||||||
if (type == LWIPERF_DUAL) {
|
if (type != LWIPERF_CLIENT) {
|
||||||
/* start corresponding server now */
|
/* start corresponding server now */
|
||||||
lwiperf_state_tcp_t *server = NULL;
|
lwiperf_state_tcp_t *server = NULL;
|
||||||
ret = lwiperf_start_tcp_server_impl(&state->conn_pcb->local_ip, LWIPERF_TCP_PORT_DEFAULT,
|
ret = lwiperf_start_tcp_server_impl(&state->conn_pcb->local_ip, LWIPERF_TCP_PORT_DEFAULT,
|
||||||
@ -794,6 +801,11 @@ void* lwiperf_start_tcp_client(const ip_addr_t* remote_addr, u16_t remote_port,
|
|||||||
/* make this server accept one connection only */
|
/* make this server accept one connection only */
|
||||||
server->specific_remote = 1;
|
server->specific_remote = 1;
|
||||||
server->remote_addr = state->conn_pcb->remote_ip;
|
server->remote_addr = state->conn_pcb->remote_ip;
|
||||||
|
if (type == LWIPERF_TRADEOFF) {
|
||||||
|
/* tradeoff means that the remote host connects only after the client is done,
|
||||||
|
so keep the listen pcb open until the client is done */
|
||||||
|
server->client_tradeoff_mode = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user