summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/cbr/cbr.c8
-rw-r--r--src/tools/oping/oping.c9
-rw-r--r--src/tools/oping/oping_client.c4
-rw-r--r--src/tools/oping/oping_server.c26
4 files changed, 28 insertions, 19 deletions
diff --git a/src/tools/cbr/cbr.c b/src/tools/cbr/cbr.c
index e42492df..27c51586 100644
--- a/src/tools/cbr/cbr.c
+++ b/src/tools/cbr/cbr.c
@@ -44,7 +44,7 @@ struct s {
static void usage(void)
{
printf("Usage: cbr [OPTION]...\n"
- "Sends SDU's from client to server at a constant bit rate.\n\n"
+ "Sends SDUs from client to server at a constant bit rate.\n\n"
" -l, --listen Run in server mode\n"
"\n"
"Server options:\n"
@@ -54,10 +54,10 @@ static void usage(void)
"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"
+ " -f, --flood Send SDUs as fast as possible\n"
" -s, --size SDU size (B)\n"
" -r, --rate Rate (b/s)\n"
- " --sleep Sleep in between sending sdu's\n"
+ " --sleep Sleep in between sending SDUs\n"
"\n\n"
" --help Display this help text and exit\n");
}
@@ -65,7 +65,7 @@ static void usage(void)
int main(int argc, char ** argv)
{
int duration = 60; /* One minute test */
- int size = 1000; /* 1000 byte SDU's */
+ int size = 1000; /* 1000 byte SDUs */
long rate = 1000000; /* 1 Mb/s */
bool flood = false;
bool sleep = false;
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index 2871e79e..7d2edf33 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -23,6 +23,9 @@
#define _POSIX_C_SOURCE 199506L
+#include <ouroboros/select.h>
+#include <ouroboros/dev.h>
+
#include <stdio.h>
#include <string.h>
#include <pthread.h>
@@ -59,9 +62,9 @@ struct c {
} client;
struct s {
- struct timespec times[OPING_MAX_FLOWS];
- bool flows[OPING_MAX_FLOWS];
- pthread_mutex_t lock;
+ struct timespec times[OPING_MAX_FLOWS];
+ struct flow_set * flows;
+ pthread_mutex_t lock;
pthread_t cleaner_pt;
pthread_t accept_pt;
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index 0d4a10af..3a254984 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -65,7 +65,7 @@ void * reader(void * o)
/* FIXME: use flow timeout option once we have it */
while(client.rcvd != client.count &&
- (fd = flow_select(&timeout)) != -ETIMEDOUT) {
+ (fd = flow_select(NULL, &timeout)) != -ETIMEDOUT) {
flow_cntl(fd, FLOW_F_SETFL, FLOW_O_NONBLOCK);
while (!((msg_len = flow_read(fd, buf, OPING_BUF_SIZE)) < 0)) {
if (msg_len < 0)
@@ -216,7 +216,7 @@ int client_main()
printf("\n");
printf("--- %s ping statistics ---\n", client.s_apn);
- printf("%d SDU's transmitted, ", client.sent);
+ printf("%d SDUs transmitted, ", client.sent);
printf("%d received, ", client.rcvd);
printf("%d%% packet loss, ", client.sent == 0 ? 0 :
100 - ((100 * client.rcvd) / client.sent));
diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c
index 7761110d..9c7b1be7 100644
--- a/src/tools/oping/oping_server.c
+++ b/src/tools/oping/oping_server.c
@@ -21,8 +21,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <ouroboros/dev.h>
-
#ifdef __FreeBSD__
#define __XSI_VISIBLE 500
#endif
@@ -53,9 +51,9 @@ void * cleaner_thread(void * o)
clock_gettime(CLOCK_REALTIME, &now);
pthread_mutex_lock(&server.lock);
for (i = 0; i < OPING_MAX_FLOWS; ++i)
- if (server.flows[i] &&
+ if (flow_set_has(server.flows, i) &&
ts_diff_ms(&server.times[i], &now) > deadline_ms) {
- server.flows[i] = false;
+ flow_set_del(server.flows, i);
flow_dealloc(i);
}
@@ -70,10 +68,16 @@ void * server_thread(void *o)
int msg_len = 0;
struct oping_msg * msg = (struct oping_msg *) buf;
struct timespec now = {0, 0};
+ struct timespec timeout = {0, 100 * MILLION};
while (true) {
-
- int fd = flow_select(NULL);
+ int fd = flow_select(server.flows, &timeout);
+ if (fd == -ETIMEDOUT)
+ continue;
+ if (fd < 0) {
+ printf("Failed to get active fd.\n");
+ continue;
+ }
while (!((msg_len = flow_read(fd, buf, OPING_BUF_SIZE)) < 0)) {
if (msg_len < 0)
continue;
@@ -126,7 +130,7 @@ void * accept_thread(void * o)
clock_gettime(CLOCK_REALTIME, &now);
pthread_mutex_lock(&server.lock);
- server.flows[fd] = true;
+ flow_set_add(server.flows, fd);
server.times[fd] = now;
pthread_mutex_unlock(&server.lock);
@@ -139,7 +143,6 @@ void * accept_thread(void * o)
int server_main()
{
struct sigaction sig_act;
- int i = 0;
memset(&sig_act, 0, sizeof sig_act);
sig_act.sa_sigaction = &shutdown_server;
@@ -153,8 +156,11 @@ int server_main()
return -1;
}
- for (i = 0; i < OPING_MAX_FLOWS; ++i)
- server.flows[i] = false;
+ server.flows = flow_set_create();
+ if (server.flows == NULL)
+ return 0;
+
+ flow_set_zero(server.flows);
pthread_create(&server.cleaner_pt, NULL, cleaner_thread, NULL);
pthread_create(&server.accept_pt, NULL, accept_thread, NULL);