summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/cbr/cbr.c2
-rw-r--r--src/tools/cbr/cbr_server.c18
-rw-r--r--src/tools/oping/oping_client.c23
3 files changed, 24 insertions, 19 deletions
diff --git a/src/tools/cbr/cbr.c b/src/tools/cbr/cbr.c
index ab178ca3..0cce50db 100644
--- a/src/tools/cbr/cbr.c
+++ b/src/tools/cbr/cbr.c
@@ -46,13 +46,13 @@ static void usage(void)
printf("Usage: cbr [OPTION]...\n"
"Sends SDU's from client to server at a constant bit rate.\n\n"
" -l, --listen Run in server mode\n"
- " -n, --server_apn Specify the name of the server.\n"
"\n"
"Server options:\n"
" -i, --interval Server report interval (s)\n"
" -t, --timeout Server timeout interval (s)\n"
"\n"
"Client options:\n"
+ " -n, --server_apn Specify the name of the server.\n"
" -d, --duration Duration for sending (s)\n"
" -f, --flood Send SDU's as fast as possible\n"
" -s, --size SDU size (B)\n"
diff --git a/src/tools/cbr/cbr_server.c b/src/tools/cbr/cbr_server.c
index 9c6ac7f1..1890c842 100644
--- a/src/tools/cbr/cbr_server.c
+++ b/src/tools/cbr/cbr_server.c
@@ -24,7 +24,7 @@
#include <stdbool.h>
#ifdef __FreeBSD__
-#define __XSI_VISIBLE
+#define __XSI_VISIBLE 500
#endif
#include <signal.h>
@@ -112,13 +112,13 @@ void handle_flow(int fd)
printf("Flow %4d: %9ld SDUs (%12ld bytes) in %9ld ms"
" => %9.4f p/s, %9.4f Mb/s\n",
fd,
- sdus-sdus_intv,
- bytes_read-bytes_read_intv,
+ sdus - sdus_intv,
+ bytes_read - bytes_read_intv,
us / 1000,
- ((sdus-sdus_intv) / (float) us) * MILLION,
- 8 * (bytes_read-bytes_read_intv)
+ ((sdus - sdus_intv) / (float) us) * MILLION,
+ 8 * (bytes_read - bytes_read_intv)
/ (float)(us));
- iv_start=iv_end;
+ iv_start = iv_end;
sdus_intv = sdus;
bytes_read_intv = bytes_read;
ts_add(&iv_start, &intv, &iv_end);
@@ -134,13 +134,13 @@ void * worker(void * o)
pthread_mutex_lock(&fds_lock);
pthread_cleanup_push((void(*)(void *)) pthread_mutex_unlock,
(void *) &fds_lock);
- while (fds[fds_index] == -1) {
+ while (fds[fds_index] == -1)
pthread_cond_wait(&fds_signal, &fds_lock);
- }
cli_fd = fds[fds_index];
fds[fds_index] = -1;
- pthread_cleanup_pop(1);
+
+ pthread_cleanup_pop(true);
handle_flow(cli_fd);
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index 23a57549..7693ce41 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -212,16 +212,21 @@ int client_main()
printf("--- %s ping statistics ---\n", client.s_apn);
printf("%d SDU's transmitted, ", client.sent);
printf("%d received, ", client.rcvd);
- printf("%d%% packet loss, ", 100 - ((100 * client.rcvd) / client.sent));
+ printf("%d%% packet loss, ", client.sent == 0 ? 0 :
+ 100 - ((100 * client.rcvd) / client.sent));
printf("time: %.3f ms\n", ts_diff_us(&tic, &toc) / 1000.0);
- printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f/",
- client.rtt_min,
- client.rtt_avg,
- client.rtt_max);
- client.rcvd > 1 ?
- printf("%.3f ms\n",
- sqrt(client.rtt_m2 / (float) (client.rcvd - 1))) :
- printf("Nan ms\n");
+
+ if (client.rcvd > 0) {
+ printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f/",
+ client.rtt_min,
+ client.rtt_avg,
+ client.rtt_max);
+ if (client.rcvd > 1)
+ printf("%.3f ms\n",
+ sqrt(client.rtt_m2 / (float) (client.rcvd - 1)));
+ else
+ printf("NaN ms\n");
+ }
pthread_mutex_lock(&client.lock);
free(client.times);