• Home
  • Raw
  • Download

Lines Matching +full:test +full:-

2  * iperf, Copyright (c) 2014-2018 The Regents of the University of
13 * acting on its behalf a paid-up, nonexclusive, irrevocable,
19 * and others acting on its behalf a paid-up, nonexclusive,
70 iperf_server_listen(struct iperf_test *test) in iperf_server_listen() argument
73 …if((test->listener = netannounce(test->settings->domain, Ptcp, test->bind_address, test->server_po… in iperf_server_listen()
74 …if (errno == EAFNOSUPPORT && (test->settings->domain == AF_INET6 || test->settings->domain == AF_U… in iperf_server_listen()
80 warning("this system does not seem to support IPv6 - trying IPv4"); in iperf_server_listen()
81 test->settings->domain = AF_INET; in iperf_server_listen()
85 return -1; in iperf_server_listen()
89 if (!test->json_output) { in iperf_server_listen()
90 iperf_printf(test, "-----------------------------------------------------------\n"); in iperf_server_listen()
91 iperf_printf(test, "Server listening on %d\n", test->server_port); in iperf_server_listen()
92 iperf_printf(test, "-----------------------------------------------------------\n"); in iperf_server_listen()
93 if (test->forceflush) in iperf_server_listen()
94 iflush(test); in iperf_server_listen()
97 FD_ZERO(&test->read_set); in iperf_server_listen()
98 FD_ZERO(&test->write_set); in iperf_server_listen()
99 FD_SET(test->listener, &test->read_set); in iperf_server_listen()
100 if (test->listener > test->max_fd) test->max_fd = test->listener; in iperf_server_listen()
106 iperf_accept(struct iperf_test *test) in iperf_accept() argument
114 if ((s = accept(test->listener, (struct sockaddr *) &addr, &len)) < 0) { in iperf_accept()
116 return -1; in iperf_accept()
119 if (test->ctrl_sck == -1) { in iperf_accept()
121 test->ctrl_sck = s; in iperf_accept()
122 if (Nread(test->ctrl_sck, test->cookie, COOKIE_SIZE, Ptcp) < 0) { in iperf_accept()
124 return -1; in iperf_accept()
126 FD_SET(test->ctrl_sck, &test->read_set); in iperf_accept()
127 if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck; in iperf_accept()
129 if (iperf_set_send_state(test, PARAM_EXCHANGE) != 0) in iperf_accept()
130 return -1; in iperf_accept()
131 if (iperf_exchange_parameters(test) < 0) in iperf_accept()
132 return -1; in iperf_accept()
133 if (test->server_affinity != -1) in iperf_accept()
134 if (iperf_setaffinity(test, test->server_affinity) != 0) in iperf_accept()
135 return -1; in iperf_accept()
136 if (test->on_connect) in iperf_accept()
137 test->on_connect(test); in iperf_accept()
140 * Don't try to read from the socket. It could block an ongoing test. in iperf_accept()
145 return -1; in iperf_accept()
156 iperf_handle_message_server(struct iperf_test *test) in iperf_handle_message_server() argument
162 if ((rval = Nread(test->ctrl_sck, (char*) &test->state, sizeof(signed char), Ptcp)) <= 0) { in iperf_handle_message_server()
164 iperf_err(test, "the client has unexpectedly closed the connection"); in iperf_handle_message_server()
166 test->state = IPERF_DONE; in iperf_handle_message_server()
170 return -1; in iperf_handle_message_server()
174 switch(test->state) { in iperf_handle_message_server()
178 test->done = 1; in iperf_handle_message_server()
179 cpu_util(test->cpu_util); in iperf_handle_message_server()
180 test->stats_callback(test); in iperf_handle_message_server()
181 SLIST_FOREACH(sp, &test->streams, streams) { in iperf_handle_message_server()
182 FD_CLR(sp->socket, &test->read_set); in iperf_handle_message_server()
183 FD_CLR(sp->socket, &test->write_set); in iperf_handle_message_server()
184 close(sp->socket); in iperf_handle_message_server()
186 test->reporter_callback(test); in iperf_handle_message_server()
187 if (iperf_set_send_state(test, EXCHANGE_RESULTS) != 0) in iperf_handle_message_server()
188 return -1; in iperf_handle_message_server()
189 if (iperf_exchange_results(test) < 0) in iperf_handle_message_server()
190 return -1; in iperf_handle_message_server()
191 if (iperf_set_send_state(test, DISPLAY_RESULTS) != 0) in iperf_handle_message_server()
192 return -1; in iperf_handle_message_server()
193 if (test->on_test_finish) in iperf_handle_message_server()
194 test->on_test_finish(test); in iperf_handle_message_server()
203 signed char oldstate = test->state; in iperf_handle_message_server()
204 cpu_util(test->cpu_util); in iperf_handle_message_server()
205 test->state = DISPLAY_RESULTS; in iperf_handle_message_server()
206 test->reporter_callback(test); in iperf_handle_message_server()
207 test->state = oldstate; in iperf_handle_message_server()
210 iperf_err(test, "the client has terminated"); in iperf_handle_message_server()
211 SLIST_FOREACH(sp, &test->streams, streams) { in iperf_handle_message_server()
212 FD_CLR(sp->socket, &test->read_set); in iperf_handle_message_server()
213 FD_CLR(sp->socket, &test->write_set); in iperf_handle_message_server()
214 close(sp->socket); in iperf_handle_message_server()
216 test->state = IPERF_DONE; in iperf_handle_message_server()
220 return -1; in iperf_handle_message_server()
229 struct iperf_test *test = client_data.p; in server_timer_proc() local
232 test->timer = NULL; in server_timer_proc()
233 if (test->done) in server_timer_proc()
235 test->done = 1; in server_timer_proc()
237 while (!SLIST_EMPTY(&test->streams)) { in server_timer_proc()
238 sp = SLIST_FIRST(&test->streams); in server_timer_proc()
239 SLIST_REMOVE_HEAD(&test->streams, streams); in server_timer_proc()
240 close(sp->socket); in server_timer_proc()
243 close(test->ctrl_sck); in server_timer_proc()
249 struct iperf_test *test = client_data.p; in server_stats_timer_proc() local
251 if (test->done) in server_stats_timer_proc()
253 if (test->stats_callback) in server_stats_timer_proc()
254 test->stats_callback(test); in server_stats_timer_proc()
260 struct iperf_test *test = client_data.p; in server_reporter_timer_proc() local
262 if (test->done) in server_reporter_timer_proc()
264 if (test->reporter_callback) in server_reporter_timer_proc()
265 test->reporter_callback(test); in server_reporter_timer_proc()
269 create_server_timers(struct iperf_test * test) in create_server_timers() argument
276 return -1; in create_server_timers()
278 cd.p = test; in create_server_timers()
279 test->timer = test->stats_timer = test->reporter_timer = NULL; in create_server_timers()
280 if (test->duration != 0 ) { in create_server_timers()
281 test->done = 0; in create_server_timers()
282test->timer = tmr_create(&now, server_timer_proc, cd, (test->duration + test->omit + 5) * SEC_TO_U… in create_server_timers()
283 if (test->timer == NULL) { in create_server_timers()
285 return -1; in create_server_timers()
289 test->stats_timer = test->reporter_timer = NULL; in create_server_timers()
290 if (test->stats_interval != 0) { in create_server_timers()
291test->stats_timer = tmr_create(&now, server_stats_timer_proc, cd, test->stats_interval * SEC_TO_US… in create_server_timers()
292 if (test->stats_timer == NULL) { in create_server_timers()
294 return -1; in create_server_timers()
297 if (test->reporter_interval != 0) { in create_server_timers()
298test->reporter_timer = tmr_create(&now, server_reporter_timer_proc, cd, test->reporter_interval * … in create_server_timers()
299 if (test->reporter_timer == NULL) { in create_server_timers()
301 return -1; in create_server_timers()
310 struct iperf_test *test = client_data.p; in server_omit_timer_proc() local
312 test->omit_timer = NULL; in server_omit_timer_proc()
313 test->omitting = 0; in server_omit_timer_proc()
314 iperf_reset_stats(test); in server_omit_timer_proc()
315 if (test->verbose && !test->json_output && test->reporter_interval == 0) in server_omit_timer_proc()
316 iperf_printf(test, "%s", report_omit_done); in server_omit_timer_proc()
319 if (test->stats_timer != NULL) in server_omit_timer_proc()
320 tmr_reset(nowP, test->stats_timer); in server_omit_timer_proc()
321 if (test->reporter_timer != NULL) in server_omit_timer_proc()
322 tmr_reset(nowP, test->reporter_timer); in server_omit_timer_proc()
326 create_server_omit_timer(struct iperf_test * test) in create_server_omit_timer() argument
331 if (test->omit == 0) { in create_server_omit_timer()
332 test->omit_timer = NULL; in create_server_omit_timer()
333 test->omitting = 0; in create_server_omit_timer()
337 return -1; in create_server_omit_timer()
339 test->omitting = 1; in create_server_omit_timer()
340 cd.p = test; in create_server_omit_timer()
341 test->omit_timer = tmr_create(&now, server_omit_timer_proc, cd, test->omit * SEC_TO_US, 0); in create_server_omit_timer()
342 if (test->omit_timer == NULL) { in create_server_omit_timer()
344 return -1; in create_server_omit_timer()
352 cleanup_server(struct iperf_test *test) in cleanup_server() argument
354 /* Close open test sockets */ in cleanup_server()
355 if (test->ctrl_sck) { in cleanup_server()
356 close(test->ctrl_sck); in cleanup_server()
358 if (test->listener) { in cleanup_server()
359 close(test->listener); in cleanup_server()
363 if (test->stats_timer != NULL) { in cleanup_server()
364 tmr_cancel(test->stats_timer); in cleanup_server()
365 test->stats_timer = NULL; in cleanup_server()
367 if (test->reporter_timer != NULL) { in cleanup_server()
368 tmr_cancel(test->reporter_timer); in cleanup_server()
369 test->reporter_timer = NULL; in cleanup_server()
371 if (test->omit_timer != NULL) { in cleanup_server()
372 tmr_cancel(test->omit_timer); in cleanup_server()
373 test->omit_timer = NULL; in cleanup_server()
375 if (test->congestion_used != NULL) { in cleanup_server()
376 free(test->congestion_used); in cleanup_server()
377 test->congestion_used = NULL; in cleanup_server()
379 if (test->timer != NULL) { in cleanup_server()
380 tmr_cancel(test->timer); in cleanup_server()
381 test->timer = NULL; in cleanup_server()
387 iperf_run_server(struct iperf_test *test) in iperf_run_server() argument
401 if (test->affinity != -1) in iperf_run_server()
402 if (iperf_setaffinity(test, test->affinity) != 0) in iperf_run_server()
403 return -2; in iperf_run_server()
405 if (test->json_output) in iperf_run_server()
406 if (iperf_json_start(test) < 0) in iperf_run_server()
407 return -2; in iperf_run_server()
409 if (test->json_output) { in iperf_run_server()
410 cJSON_AddItemToObject(test->json_start, "version", cJSON_CreateString(version)); in iperf_run_server()
411 cJSON_AddItemToObject(test->json_start, "system_info", cJSON_CreateString(get_system_info())); in iperf_run_server()
412 } else if (test->verbose) { in iperf_run_server()
413 iperf_printf(test, "%s\n", version); in iperf_run_server()
414 iperf_printf(test, "%s", ""); in iperf_run_server()
415 iperf_printf(test, "%s\n", get_system_info()); in iperf_run_server()
416 iflush(test); in iperf_run_server()
420 if (iperf_server_listen(test) < 0) { in iperf_run_server()
421 return -2; in iperf_run_server()
427 test->state = IPERF_START; in iperf_run_server()
431 while (test->state != IPERF_DONE) { in iperf_run_server()
433 memcpy(&read_set, &test->read_set, sizeof(fd_set)); in iperf_run_server()
434 memcpy(&write_set, &test->write_set, sizeof(fd_set)); in iperf_run_server()
438 result = select(test->max_fd + 1, &read_set, &write_set, NULL, timeout); in iperf_run_server()
440 cleanup_server(test); in iperf_run_server()
442 return -1; in iperf_run_server()
445 if (FD_ISSET(test->listener, &read_set)) { in iperf_run_server()
446 if (test->state != CREATE_STREAMS) { in iperf_run_server()
447 if (iperf_accept(test) < 0) { in iperf_run_server()
448 cleanup_server(test); in iperf_run_server()
449 return -1; in iperf_run_server()
451 FD_CLR(test->listener, &read_set); in iperf_run_server()
454 if (test->mode == BIDIRECTIONAL) { in iperf_run_server()
455 streams_to_send = test->num_streams; in iperf_run_server()
456 streams_to_rec = test->num_streams; in iperf_run_server()
457 } else if (test->mode == RECEIVER) { in iperf_run_server()
458 streams_to_rec = test->num_streams; in iperf_run_server()
461 streams_to_send = test->num_streams; in iperf_run_server()
466 if (FD_ISSET(test->ctrl_sck, &read_set)) { in iperf_run_server()
467 if (iperf_handle_message_server(test) < 0) { in iperf_run_server()
468 cleanup_server(test); in iperf_run_server()
469 return -1; in iperf_run_server()
471 FD_CLR(test->ctrl_sck, &read_set); in iperf_run_server()
474 if (test->state == CREATE_STREAMS) { in iperf_run_server()
475 if (FD_ISSET(test->prot_listener, &read_set)) { in iperf_run_server()
477 if ((s = test->protocol->accept(test)) < 0) { in iperf_run_server()
478 cleanup_server(test); in iperf_run_server()
479 return -1; in iperf_run_server()
483 if (test->protocol->id == Ptcp) { in iperf_run_server()
484 if (test->congestion) { in iperf_run_server()
485 … if (setsockopt(s, IPPROTO_TCP, TCP_CONGESTION, test->congestion, strlen(test->congestion)) < 0) { in iperf_run_server()
501 cleanup_server(test); in iperf_run_server()
504 return -1; in iperf_run_server()
514 cleanup_server(test); in iperf_run_server()
517 return -1; in iperf_run_server()
519 test->congestion_used = strdup(ca); in iperf_run_server()
520 if (test->debug) { in iperf_run_server()
521 printf("Congestion algorithm is %s\n", test->congestion_used); in iperf_run_server()
537 if (flag != -1) { in iperf_run_server()
538 sp = iperf_new_stream(test, s, flag); in iperf_run_server()
540 cleanup_server(test); in iperf_run_server()
541 return -1; in iperf_run_server()
544 if (sp->sender) in iperf_run_server()
545 FD_SET(s, &test->write_set); in iperf_run_server()
547 FD_SET(s, &test->read_set); in iperf_run_server()
549 if (s > test->max_fd) test->max_fd = s; in iperf_run_server()
557 if (test->protocol->id != Pudp || in iperf_run_server()
558 !sp->sender) { in iperf_run_server()
562 if (test->on_new_stream) in iperf_run_server()
563 test->on_new_stream(sp); in iperf_run_server()
565 flag = -1; in iperf_run_server()
568 FD_CLR(test->prot_listener, &read_set); in iperf_run_server()
573 if (test->protocol->id != Ptcp) { in iperf_run_server()
574 FD_CLR(test->prot_listener, &test->read_set); in iperf_run_server()
575 close(test->prot_listener); in iperf_run_server()
577 … if (test->no_delay || test->settings->mss || test->settings->socket_bufsize) { in iperf_run_server()
578 FD_CLR(test->listener, &test->read_set); in iperf_run_server()
579 close(test->listener); in iperf_run_server()
580 test->listener = 0; in iperf_run_server()
581 … if ((s = netannounce(test->settings->domain, Ptcp, test->bind_address, test->server_port)) < 0) { in iperf_run_server()
582 cleanup_server(test); in iperf_run_server()
584 return -1; in iperf_run_server()
586 test->listener = s; in iperf_run_server()
587 FD_SET(test->listener, &test->read_set); in iperf_run_server()
588 if (test->listener > test->max_fd) test->max_fd = test->listener; in iperf_run_server()
591 test->prot_listener = -1; in iperf_run_server()
592 if (iperf_set_send_state(test, TEST_START) != 0) { in iperf_run_server()
593 cleanup_server(test); in iperf_run_server()
594 return -1; in iperf_run_server()
596 if (iperf_init_test(test) < 0) { in iperf_run_server()
597 cleanup_server(test); in iperf_run_server()
598 return -1; in iperf_run_server()
600 if (create_server_timers(test) < 0) { in iperf_run_server()
601 cleanup_server(test); in iperf_run_server()
602 return -1; in iperf_run_server()
604 if (create_server_omit_timer(test) < 0) { in iperf_run_server()
605 cleanup_server(test); in iperf_run_server()
606 return -1; in iperf_run_server()
608 if (test->mode != RECEIVER) in iperf_run_server()
609 if (iperf_create_send_timers(test) < 0) { in iperf_run_server()
610 cleanup_server(test); in iperf_run_server()
611 return -1; in iperf_run_server()
613 if (iperf_set_send_state(test, TEST_RUNNING) != 0) { in iperf_run_server()
614 cleanup_server(test); in iperf_run_server()
615 return -1; in iperf_run_server()
620 if (test->state == TEST_RUNNING) { in iperf_run_server()
621 if (test->mode == BIDIRECTIONAL) { in iperf_run_server()
622 if (iperf_recv(test, &read_set) < 0) { in iperf_run_server()
623 cleanup_server(test); in iperf_run_server()
624 return -1; in iperf_run_server()
626 if (iperf_send(test, &write_set) < 0) { in iperf_run_server()
627 cleanup_server(test); in iperf_run_server()
628 return -1; in iperf_run_server()
630 } else if (test->mode == SENDER) { in iperf_run_server()
632 if (iperf_send(test, &write_set) < 0) { in iperf_run_server()
633 cleanup_server(test); in iperf_run_server()
634 return -1; in iperf_run_server()
638 if (iperf_recv(test, &read_set) < 0) { in iperf_run_server()
639 cleanup_server(test); in iperf_run_server()
640 return -1; in iperf_run_server()
647 (timeout != NULL && timeout->tv_sec == 0 && timeout->tv_usec == 0)) { in iperf_run_server()
654 cleanup_server(test); in iperf_run_server()
656 if (test->json_output) { in iperf_run_server()
657 if (iperf_json_finish(test) < 0) in iperf_run_server()
658 return -1; in iperf_run_server()
661 iflush(test); in iperf_run_server()
663 if (test->server_affinity != -1) in iperf_run_server()
664 if (iperf_clearaffinity(test) != 0) in iperf_run_server()
665 return -1; in iperf_run_server()