-/* ***************************************************************************
- * 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 hosts
+ *
+ * \arg from_name: Name of the first host
+ * \arg from_port: port on which the first process is listening for messages
+ * \arg to_name: Name of the second host
+ * \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 exp_size: Total size of data sent across the network
+ * \arg msg_size: Size of each message sent. (\e expSize % \e msgSize) messages will be sent.
+ * \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_host:from_port to to_host:to_port.
+ * This call is blocking until the end of the experiment.
+ *
+ * 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 exp_size,
+ unsigned long int msg_size,
+ /*OUT*/ double *sec, double*bw) {
+
+ gras_socket_t sock;