-int grasbw_cbBWRequest(gras_msg_t *msg) {
- /* specification of the test to run */
- char* to_name=gras_msg_ctn(msg,0,0,msgHost_t).host;
- unsigned int to_port=gras_msg_ctn(msg,0,0,msgHost_t).port;
-
- unsigned int bufSize=gras_msg_ctn(msg,1,0,BwExp_t).bufSize;
- unsigned int expSize=gras_msg_ctn(msg,1,0,BwExp_t).expSize;
- unsigned int msgSize=gras_msg_ctn(msg,1,0,BwExp_t).msgSize;
- /* our answer */
- msgError_t *error;
- msgResult_t *res;
-
- if (!(error=(msgError_t *)malloc(sizeof(msgError_t))) ||
- !(res=(msgResult_t *)malloc(sizeof(msgResult_t) * 2))) {
- fprintf(stderr,"%s:%d:grasbw_cbRequest: Malloc error\n",__FILE__,__LINE__);
- return malloc_error;
- }
-
- if ((error->errcode=grasbw_test(to_name,to_port,bufSize,expSize,msgSize,
- &(res[0].value),&(res[1].value) ))) {
- fprintf(stderr,
- "%s:%d:grasbw_cbRequest: Error %s encountered while doing the test\n",
- __FILE__,__LINE__,xbt_error_name(error->errcode));
- strncpy(error->errmsg,"Error within grasbw_test",ERRMSG_LEN);
- gras_msg_new_and_send(msg->sock,GRASMSG_BW_RESULT,2,
- error,1,
- res,2);
- return 1;
- }
- res[0].timestamp = (unsigned int) gras_time();
- res[1].timestamp = (unsigned int) gras_time();
- gras_msg_new_and_send(msg->sock,GRASMSG_BW_RESULT,2,
- error,1,
- res,2);
- gras_msg_free(msg);
- return 1;
-}
-
-/* ***************************************************************************
- * Link saturation
- * ***************************************************************************/
-
-xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port,
- unsigned int msgSize, unsigned int timeout) {
- gras_sock_t *sock;
- xbt_error_t errcode;
- /* The request */
- SatExp_t *request;
- msgHost_t *target;
- /* answer */
- gras_msg_t *answer;
-
- if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
- fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while contacting peer\n",
- __FILE__,__LINE__,xbt_error_name(errcode));
- return errcode;
- }
- if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t))) ||
- !(target=(msgHost_t*)malloc(sizeof(msgHost_t)))) {
- fprintf(stderr,"%s:%d:saturate_start(): Malloc error\n",__FILE__,__LINE__);
- gras_sock_close(sock);
- return malloc_error;
- }
-
- request->timeout=timeout;
- request->msgSize=msgSize;
-
- strcpy(target->host,to_name);
- target->port=to_port;
-
- if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_START, 2,
- target,1,
- request,1))) {
- fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while sending the request.\n",
- __FILE__,__LINE__,xbt_error_name(errcode));
- gras_sock_close(sock);
- return errcode;
- }
- if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STARTED,&answer))) {
- fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while waiting for the ACK.\n",
- __FILE__,__LINE__,xbt_error_name(errcode));
- gras_sock_close(sock);
- return errcode;
- }
-
- if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
- fprintf(stderr,"%s:%d:saturate_start(): Peer reported error %s (%s).\n",
- __FILE__,__LINE__,xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
- gras_msg_free(answer);
- gras_sock_close(sock);
- return errcode;
- }
-
- gras_msg_free(answer);
- gras_sock_close(sock);
- return no_error;
-}
-
-int grasbw_cbSatStart(gras_msg_t *msg) {
- gras_rawsock_t *raw;
- gras_sock_t *sock;
- xbt_error_t errcode;
- double start; /* time to timeout */
-
- /* specification of the test to run */
- char* to_name=gras_msg_ctn(msg,0,0,msgHost_t).host;
- unsigned int to_port=gras_msg_ctn(msg,0,0,msgHost_t).port;
-
- unsigned int msgSize=gras_msg_ctn(msg,1,0,SatExp_t).msgSize;
- unsigned int timeout=gras_msg_ctn(msg,1,0,SatExp_t).timeout;
- unsigned int raw_port;
-
+/**
+ * \brief request a bandwidth measurement between two remote peers
+ *
+ * \arg from_name: Name of the first peer
+ * \arg from_port: port on which the first process is listening for messages
+ * \arg to_name: Name of the second peer
+ * \arg to_port: port on which the second process is listening (for messages, do not
+ * give a measurement socket here. The needed measurement sockets will be created
+ * automatically and negociated between the peers)
+ * \arg buf_size: Size of the socket buffer. If 0, a sain default is used (32k, but may change)
+ * \arg msg_size: Size of each message sent.
+ * \arg msg_amount: Amount of such data to exchange
+ * \arg sec: where the result (in seconds) should be stored.
+ * \arg bw: observed Bandwidth (in byte/s)
+ *
+ * Conduct a bandwidth test from the process from_peer:from_port to to_peer:to_port.
+ * This call is blocking until the end of the experiment.
+ *
+ * @warning: in SimGrid version 3.1 and previous, the experiment size were specified
+ * as the total amount of data to send and the msg_size. This
+ * was changed for the fool wanting to send more than MAXINT
+ * bytes in a fat pipe.
+ *
+ * Results are reported in last args, and sizes are in bytes.
+ */
+void amok_bw_request(const char *from_name, unsigned int from_port,
+ const char *to_name, unsigned int to_port,
+ unsigned long int buf_size,
+ unsigned long int msg_size,
+ unsigned long int msg_amount,
+ double min_duration, /*OUT*/ double *sec, double *bw)
+{
+
+ gras_socket_t sock;