3 /* bandwidth - bandwidth test demo of GRAS features */
5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2003 the OURAGAN project. */
8 /* This program is free software; you can redistribute it and/or modify it
9 under the terms of the license (GNU LGPL) which comes with this package. */
17 /* **********************************************************************
19 * **********************************************************************/
21 /* Global private data */
26 /* Function prototypes */
27 int sensor (int argc,char *argv[]);
29 int sensor (int argc,char *argv[]) {
31 sensor_data_t *g=gras_userdata_new(sensor_data_t);
33 if ((errcode=gras_sock_server_open(4000,4000,&(g->sock)))) {
34 fprintf(stderr,"Sensor: Error %s encountered while opening the server socket\n",gras_error_name(errcode));
38 if (grasbw_register_messages()) {
39 gras_sock_close(g->sock);
44 if ((errcode=gras_msg_handle(60.0)) && errcode != timeout_error) {
45 fprintf(stderr,"Sensor: Error '%s' while handling message\n",gras_error_name(errcode));
46 gras_sock_close(g->sock);
49 if (errcode==no_error)
54 return gras_sock_close(g->sock);
57 /* **********************************************************************
59 * **********************************************************************/
61 /* Global private data */
66 /* Function prototypes */
67 int maestro (int argc,char *argv[]);
69 int maestro(int argc,char *argv[]) {
71 maestro_data_t *g=gras_userdata_new(maestro_data_t);
73 int bufSize=32 * 1024;
74 int expSize=64 * 1024;
75 int msgSize=64 * 1024;
77 if ((errcode=gras_sock_server_open(4000,5000,&(g->sock)))) {
78 fprintf(stderr,"Maestro: Error %s encountered while opening the server socket\n",gras_error_name(errcode));
82 if (grasbw_register_messages()) {
83 gras_sock_close(g->sock);
88 fprintf(stderr,"Usage: maestro host port host port\n");
92 if ((errcode=grasbw_request(argv[1],atoi(argv[2]),argv[3],atoi(argv[4]),
93 bufSize,expSize,msgSize,&sec,&bw))) {
94 fprintf(stderr,"maestro: Error %s encountered while doing the test\n",gras_error_name(errcode));
98 fprintf(stderr,"maestro: Experience (%d ko in msgs of %d ko) took %f sec, achieving %f Mb/s\n",
99 expSize/1024,msgSize/1024,
103 return gras_sock_close(g->sock);