3 /* bandwidth - bandwidth test demo of GRAS features */
5 /* Copyright (c) 2004 Martin Quinson. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include "amok/bandwidth.h"
14 XBT_LOG_NEW_DEFAULT_CATEGORY(Bandwidth,"Messages specific to this example");
16 /* **********************************************************************
18 * **********************************************************************/
20 /* Global private data */
23 } s_sensor_data_t,*sensor_data_t;
25 /* Function prototypes */
26 int sensor (int argc,char *argv[]);
28 int sensor (int argc,char *argv[]) {
33 g=gras_userdata_new(s_sensor_data_t);
37 if ((errcode=gras_socket_server(atoi(argv[1]),&(g->sock)))) {
38 ERROR1("Sensor: Error %s encountered while opening the server socket",xbt_error_name(errcode));
42 errcode=gras_msg_handle(60.0);
43 if (errcode != no_error) {
44 ERROR1("Sensor: Error '%s' while handling message",xbt_error_name(errcode));
45 gras_socket_close(g->sock);
49 gras_socket_close(g->sock);
53 /* **********************************************************************
55 * **********************************************************************/
57 /* Global private data */
60 } s_maestro_data_t,*maestro_data_t;
62 /* Function prototypes */
63 int maestro (int argc,char *argv[]);
65 int maestro(int argc,char *argv[]) {
75 g=gras_userdata_new(s_maestro_data_t);
79 if ((errcode=gras_socket_server(6000,&(g->sock)))) {
80 ERROR1("Maestro: Error %s encountered while opening the server socket",xbt_error_name(errcode));
86 ERROR0("Usage: maestro host port host port\n");
90 if ((errcode=gras_socket_client(argv[1],atoi(argv[2]),&peer))) {
91 ERROR3("Client: Unable to connect to my peer on %s:%s. Got %s",
92 argv[1],argv[2],xbt_error_name(errcode));
96 /* if ((errcode=amok_bw_request(argv[1],atoi(argv[2]),argv[3],atoi(argv[4]),
97 buf_size,exp_size,msg_size,&sec,&bw))) {*/
99 if ((errcode=amok_bw_test(peer,buf_size,exp_size,msg_size,&sec,&bw))) {
100 ERROR1("maestro: Error %s encountered while doing the test",xbt_error_name(errcode));
104 INFO6("maestro: Experience between me and %s:%d (%d ko in msgs of %d ko) took %f sec, achieving %f Mb/s",
105 argv[1],atoi(argv[2]),
109 gras_socket_close(g->sock);