Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
raising errors now use logging and not printf. We thus need a default log channel...
[simgrid.git] / src / amok / bandwidth.c
index 167559c..8e4afc3 100644 (file)
 /* $Id$ */
 
-/* gras_bandwidth - GRAS mecanism to do Bandwidth tests between to hosts    */
+/* amok_bandwidth - Bandwidth tests facilities                              */
 
-/* Authors: Martin Quinson                                                  */
-/* Copyright (C) 2003 the OURAGAN project.                                  */
+/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
 
 /* This program is free software; you can redistribute it and/or modify it
  under the terms of the license (GNU LGPL) which comes with this package. */
* under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include <gras.h>
+#include "gras/messages.h"
+#include "amok/bandwidth.h"
 
 /**
- * BwExp_t:
+ * bw_request_t:
  *
- * Description of a BW experiment (payload when asking an host to do a BW experiment with us)
+ * Request for a BW experiment.
+ * If host==NULL, it should be between the sender and the receiver.
+ * If not, it should be between between the receiver and @host (3-tiers).
  */
 typedef struct {
-  unsigned int bufSize;
-  unsigned int expSize;
-  unsigned int msgSize;
-  unsigned int port;    /* raw socket to use */
-} BwExp_t;
-
-static const DataDescriptor BwExp_Desc[] = 
- { SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(BwExp_t,bufSize)),
-   SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(BwExp_t,expSize)),
-   SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(BwExp_t,msgSize)),
-   SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(BwExp_t,port))};
-#define BwExp_Len 4
+  xbt_host_t host; /* host+raw socket to use */
+  unsigned int buf_size;
+  unsigned int exp_size;
+  unsigned int msg_size;
+} bw_request_t;
 
 /**
- * SatExp_t:
+ * bw_res_t:
  *
- * Description of a BW experiment (payload when asking an host to do a BW experiment with us)
+ * Result of a BW experiment (payload when answering).
+ * if err.msg != NULL, it wasn't sucessful. Check err.msg and err.code to see why.
+ * else
  */
 typedef struct {
-  unsigned int msgSize;
-  unsigned int timeout;
-  unsigned int port;    /* raw socket to use */
-} SatExp_t;
+  amok_remoterr_t err;
+  unsigned int timestamp;
+  double seconds;
+  double bw;
+} bw_res_t;
 
-static const DataDescriptor SatExp_Desc[] = 
- { SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(SatExp_t,msgSize)),
-   SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(SatExp_t,timeout)),
-   SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(SatExp_t,port))};
-#define SatExp_Len 3
 
+/**
+ * sat_request_t:
+ *
+ * Description of a saturation experiment (payload asking some host to collaborate for that)
+ */
+typedef struct {
+  xbt_host_t host; /* host+raw socket to use */
+  unsigned int msg_size;
+  unsigned int timeout;
+} sat_request_t;
 
 /* Prototypes of local callbacks */
-int grasbw_cbBWHandshake(gras_msg_t *msg);
-int grasbw_cbBWRequest(gras_msg_t *msg);
+int amok_bw_cb_bw_handshake(gras_socket_t *expeditor,
+                           void          *payload);
+int amok_bw_cb_bw_request(gras_socket_t   *expeditor,
+                         void            *payload);
 
-int grasbw_cbSatStart(gras_msg_t *msg);
-int grasbw_cbSatBegin(gras_msg_t *msg);
+int amok_bw_cb_sat_start(gras_socket_t    *expeditor,
+                        void             *payload);
+int amok_bw_cb_sat_begin(gras_socket_t    *expeditor,
+                        void             *payload);
 
 /**** code ****/
-gras_error_t grasbw_register_messages(void) {
-  gras_error_t errcode;
-
-  
-  if ( /* Bandwidth */
-      (errcode=gras_msgtype_register(GRASMSG_BW_REQUEST,"BW request",2,
-                              msgHostDesc,msgHostLen,
-                              BwExp_Desc,BwExp_Len)) ||
-      (errcode=gras_msgtype_register(GRASMSG_BW_RESULT, "BW result",2,
-                              msgErrorDesc,msgErrorLen,
-                              msgResultDesc,msgResultLen /* first=seconds, second=bw */)) ||
-      
-      (errcode=gras_msgtype_register(GRASMSG_BW_HANDSHAKE, "BW handshake",1,
-                              BwExp_Desc,BwExp_Len))  || 
-      (errcode=gras_msgtype_register(GRASMSG_BW_HANDSHAKED, "BW handshake ACK",1,
-                              BwExp_Desc,BwExp_Len)) ||
-      
-      /* Saturation */
-      (errcode=gras_msgtype_register(GRASMSG_SAT_START,"SAT_START",2,
-                              msgHostDesc,msgHostLen,
-                              SatExp_Desc,SatExp_Len)) ||
-      (errcode=gras_msgtype_register(GRASMSG_SAT_STARTED, "SAT_STARTED",1,
-                              msgErrorDesc,msgErrorLen)) ||
-      
-      (errcode=gras_msgtype_register(GRASMSG_SAT_BEGIN,"SAT_BEGIN",1,
-                              SatExp_Desc,SatExp_Len)) ||
-      (errcode=gras_msgtype_register(GRASMSG_SAT_BEGUN, "SAT_BEGUN",2,
-                              msgErrorDesc,msgErrorLen,
-                              SatExp_Desc,SatExp_Len)) ||
-      
-      (errcode=gras_msgtype_register(GRASMSG_SAT_END,"SAT_END",0)) ||
-      (errcode=gras_msgtype_register(GRASMSG_SAT_ENDED, "SAT_ENDED",1,
-                              msgErrorDesc,msgErrorLen)) ||
-      
-      (errcode=gras_msgtype_register(GRASMSG_SAT_STOP,"SAT_STOP",0)) ||
-      (errcode=gras_msgtype_register(GRASMSG_SAT_STOPPED, "SAT_STOPPED",1,
-                              msgErrorDesc,msgErrorLen)) ) 
-    {
-
-      fprintf(stderr,"GRASBW: Unable register the messages (got error %s)\n",
-             gras_error_name(errcode));
-      return errcode;
-    }
-
-  if ((errcode=gras_cb_register(GRASMSG_BW_HANDSHAKE,-1,&grasbw_cbBWHandshake)) ||
-      (errcode=gras_cb_register(GRASMSG_BW_REQUEST,-1,&grasbw_cbBWRequest))  ||
-
-      (errcode=gras_cb_register(GRASMSG_SAT_START,-1,&grasbw_cbSatStart))  ||
-      (errcode=gras_cb_register(GRASMSG_SAT_BEGIN,-1,&grasbw_cbSatBegin)) ) {
-
-    fprintf(stderr,"GRASBW: Unable register the callbacks (got error %s)\n",
-           gras_error_name(errcode));
-    return errcode;
-  }
-
-  return no_error;
+void amok_bw_init(void) {
+  xbt_error_t errcode;
+  gras_datadesc_type_t *bw_request_desc, *bw_res_desc, *sat_request_desc;
+
+  amok_base_init();
+   
+  /* Build the datatype descriptions */ 
+  bw_request_desc = gras_datadesc_struct("bw_request_t");
+  gras_datadesc_struct_append(bw_request_desc,"host",gras_datadesc_by_name("xbt_host_t*"));
+  gras_datadesc_struct_append(bw_request_desc,"buf_size",gras_datadesc_by_name("unsigned int"));
+  gras_datadesc_struct_append(bw_request_desc,"exp_size",gras_datadesc_by_name("unsigned int"));
+  gras_datadesc_struct_append(bw_request_desc,"msg_size",gras_datadesc_by_name("unsigned int"));
+  gras_datadesc_struct_close(bw_request_desc);
+  bw_request_desc = gras_datadesc_ref("bw_request_t*",bw_request_desc);
+
+  bw_res_desc = gras_datadesc_struct("bw_res_t");
+  gras_datadesc_struct_append(bw_res_desc,"err",gras_datadesc_by_name("amok_remoterr_t"));
+  gras_datadesc_struct_append(bw_res_desc,"timestamp",gras_datadesc_by_name("unsigned int"));
+  gras_datadesc_struct_append(bw_res_desc,"seconds",gras_datadesc_by_name("double"));
+  gras_datadesc_struct_append(bw_res_desc,"bw",gras_datadesc_by_name("double"));
+  gras_datadesc_struct_close(bw_res_desc);
+  bw_res_desc = gras_datadesc_ref("bw_res_t*",bw_res_desc);
+
+  sat_request_desc = gras_datadesc_struct("sat_request_desc");
+  gras_datadesc_struct_append(sat_request_desc,"host",gras_datadesc_by_name("xbt_host_t"));
+  gras_datadesc_struct_append(sat_request_desc,"msg_size",gras_datadesc_by_name("unsigned int"));
+  gras_datadesc_struct_append(sat_request_desc,"timeout",gras_datadesc_by_name("unsigned int"));
+  gras_datadesc_struct_close(sat_request_desc);
+  sat_request_desc = gras_datadesc_ref("sat_request_t*",sat_request_desc);
+   
+  /* Register the bandwidth messages */
+  gras_msgtype_declare("BW request",       bw_request_desc);
+  gras_msgtype_declare("BW result",        bw_res_desc);
+  gras_msgtype_declare("BW handshake",     bw_request_desc);
+  gras_msgtype_declare("BW handshake ACK", bw_request_desc);
+
+  /* Register the saturation messages */
+  gras_msgtype_declare("SAT start",   sat_request_desc);
+  gras_msgtype_declare("SAT started", gras_datadesc_by_name("amok_remoterr_t"));
+  gras_msgtype_declare("SAT begin",   sat_request_desc);
+  gras_msgtype_declare("SAT begun",   gras_datadesc_by_name("amok_remoterr_t"));
+  gras_msgtype_declare("SAT end",     NULL);
+  gras_msgtype_declare("SAT ended",   gras_datadesc_by_name("amok_remoterr_t"));
+  gras_msgtype_declare("SAT stop",    NULL);
+  gras_msgtype_declare("SAT stopped", gras_datadesc_by_name("amok_remoterr_t"));
+
+  /* Register the callbacks */
+  gras_cb_register(gras_msgtype_by_name("BW request"),
+                  &amok_bw_cb_bw_request);
+  gras_cb_register(gras_msgtype_by_name("BW handshake"),
+                  &amok_bw_cb_bw_handshake);
+
+  gras_cb_register(gras_msgtype_by_name("SAT start"),
+                  &amok_bw_cb_sat_start);
+  gras_cb_register(gras_msgtype_by_name("SAT begin"),
+                  &amok_bw_cb_sat_begin);
 }
 
 /* ***************************************************************************
  * Bandwidth tests
  * ***************************************************************************/
 /* Function to do a test from local to given host */
-gras_error_t grasbw_test(const char*to_name,unsigned int to_port,
-                       unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
-                       /*OUT*/ double *sec, double *bw) {
-  gras_rawsock_t *rawIn,*rawOut;
-  gras_sock_t *sock;
-  gras_error_t errcode;
-  BwExp_t *request;
+/**
+ * amok_bw_test:
+ * 
+ * Conduct a test between the local host and @peer, and 
+ * report the result in last args
+ */
+xbt_error_t amok_bw_test(gras_socket_t *peer,
+                         unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
+                         /*OUT*/ double *sec, double *bw) {
+  gras_socket_t *rawIn,*rawOut;
+  int port;
+  xbt_error_t errcode;
+  bw_request_t *request;
   gras_msg_t *answer;
   
-  if((errcode=gras_sock_client_open(to_name,to_port,&sock))) {
-    fprintf(stderr,"grasbw_test(): Error %s encountered while contacting peer\n",
-           gras_error_name(errcode));
-    return errcode;
-  }
-  if ((errcode=gras_rawsock_server_open(6666,8000,bufSize,&rawIn))) { 
-    fprintf(stderr,"grasbw_test(): Error %s encountered while opening a raw socket\n",
-           gras_error_name(errcode));
+  for (port = 5000, errcode = system_error;
+       errcode == system_error;
+       errcode = gras_socket_server_ext(++port,bufSize,1,&rawIn));
+  if (errcode != no_error) {
+    ERROR1("Error %s encountered while opening a raw socket\n",
+          xbt_error_name(errcode));
     return errcode;
   }
 
-  if (!(request=(BwExp_t *)malloc(sizeof(BwExp_t)))) {
-    fprintf(stderr,"grasbw_test(): Malloc error\n");
-    gras_sock_close(sock);
-    return malloc_error;    
-  }
+  request=xbt_new(bw_request_t);
   request->bufSize=bufSize;
   request->expSize=expSize;
   request->msgSize=msgSize;
-  request->port=gras_rawsock_get_peer_port(rawIn);
+  request->host.name = NULL;
+  request->host.port = gras_socket_peer_port(rawIn);
 
-  if ((errcode=gras_msg_new_and_send(sock,GRASMSG_BW_HANDSHAKE, 1, 
-                             request,1))) {
-    fprintf(stderr,"grasbw_test(): Error %s encountered while sending the request.\n",
-           gras_error_name(errcode));
+  if ((errcode=gras_send(peer,gras_msgtype_by_name("BW handshake"),request))) {
+    ERROR1("Error %s encountered while sending the request.", xbt_error_name(errcode));
     gras_sock_close(sock);
     return errcode;
   }
   if ((errcode=gras_msg_wait(60,GRASMSG_BW_HANDSHAKED,&answer))) {
     fprintf(stderr,"grasbw_test(): Error %s encountered while waiting for the answer.\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_sock_close(sock);
     return errcode;
   }
   if((errcode=gras_rawsock_client_open(to_name,gras_msg_ctn(answer,0,0,BwExp_t).port,
                                    bufSize,&rawOut))) {
     fprintf(stderr,"grasbw_test(): Error %s encountered while opening the raw socket to %s:%d\n",
-           gras_error_name(errcode),to_name,gras_msg_ctn(answer,0,0,BwExp_t).port);
+           xbt_error_name(errcode),to_name,gras_msg_ctn(answer,0,0,BwExp_t).port);
     return errcode;
   }
 
@@ -175,7 +181,7 @@ gras_error_t grasbw_test(const char*to_name,unsigned int to_port,
   if ((errcode=gras_rawsock_send(rawOut,expSize,msgSize)) ||
       (errcode=gras_rawsock_recv(rawIn,1,1,120))) {
     fprintf(stderr,"grasbw_test(): Error %s encountered while sending the experiment.\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_rawsock_close(rawOut);
     gras_rawsock_close(rawIn);
     return errcode;
@@ -190,6 +196,9 @@ gras_error_t grasbw_test(const char*to_name,unsigned int to_port,
   return no_error;
 }
 
+#if 0
+
+
 /* Callback to the GRASMSG_BW_HANDSHAKE message: 
    opens a server raw socket,
    indicate its port in an answer GRASMSG_BW_HANDSHAKED message,
@@ -199,17 +208,17 @@ gras_error_t grasbw_test(const char*to_name,unsigned int to_port,
 int grasbw_cbBWHandshake(gras_msg_t *msg) {
   gras_rawsock_t *rawIn,*rawOut;
   BwExp_t *ans;
-  gras_error_t errcode;
+  xbt_error_t errcode;
   
   if ((errcode=gras_rawsock_server_open(6666,8000,gras_msg_ctn(msg,0,0,BwExp_t).bufSize,&rawIn))) { 
     fprintf(stderr,"grasbw_cbHandshake(): Error %s encountered while opening a raw socket\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     return 1;
   }
   if ((errcode=gras_rawsock_client_open(gras_sock_get_peer_name(msg->sock),gras_msg_ctn(msg,0,0,BwExp_t).port,
                                     gras_msg_ctn(msg,0,0,BwExp_t).bufSize,&rawOut))) { 
     fprintf(stderr,"grasbw_cbHandshake(): Error %s encountered while opening a raw socket\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     return 1;
   }
   if (!(ans=(BwExp_t *)malloc(sizeof(BwExp_t)))) {
@@ -228,7 +237,7 @@ int grasbw_cbBWHandshake(gras_msg_t *msg) {
   if ((errcode=gras_msg_new_and_send(msg->sock,GRASMSG_BW_HANDSHAKED, 1,
                              ans, 1))) {
     fprintf(stderr,"grasbw_cbHandshake(): Error %s encountered while sending the answer.\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_rawsock_close(rawIn);
     gras_rawsock_close(rawOut);
     return 1;
@@ -240,7 +249,7 @@ int grasbw_cbBWHandshake(gras_msg_t *msg) {
                               120)) ||
       (errcode=gras_rawsock_send(rawOut,1,1))) {
     fprintf(stderr,"grasbw_cbHandshake(): Error %s encountered while receiving the experiment.\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_rawsock_close(rawIn);
     gras_rawsock_close(rawOut);
     return 1;
@@ -252,21 +261,21 @@ int grasbw_cbBWHandshake(gras_msg_t *msg) {
 }
 
 /* function to request a BW test between to external hosts */
-gras_error_t grasbw_request(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_request(const char* from_name,unsigned int from_port,
                           const char* to_name,unsigned int to_port,
                           unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
                           /*OUT*/ double *sec, double*bw) {
   
   gras_sock_t *sock;
   gras_msg_t *answer;
-  gras_error_t errcode;
+  xbt_error_t errcode;
   /* The request */
   BwExp_t *request;
   msgHost_t *target;
 
   if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
     fprintf(stderr,"grasbw_request(): Error %s encountered while contacting the actuator\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     return errcode;
   }
   if (!(request=(BwExp_t *)malloc(sizeof(BwExp_t))) ||
@@ -286,20 +295,20 @@ gras_error_t grasbw_request(const char* from_name,unsigned int from_port,
                              target,1,
                              request,1))) {
     fprintf(stderr,"grasbw_request(): Error %s encountered while sending the request.\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_sock_close(sock);
     return errcode;
   }
   if ((errcode=gras_msg_wait(240,GRASMSG_BW_RESULT,&answer))) {
     fprintf(stderr,"grasbw_request(): Error %s encountered while waiting for the answer.\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_sock_close(sock);
     return errcode;
   }
 
   if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
     fprintf(stderr,"grasbw_request(): Peer reported error %s (%s).\n",
-           gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+           xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
     gras_msg_free(answer);
     gras_sock_close(sock);
     return errcode;
@@ -336,7 +345,7 @@ int grasbw_cbBWRequest(gras_msg_t *msg) {
                                  &(res[0].value),&(res[1].value) ))) {
     fprintf(stderr,
            "%s:%d:grasbw_cbRequest: Error %s encountered while doing the test\n",
-           __FILE__,__LINE__,gras_error_name(error->errcode));
+           __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,
@@ -356,11 +365,11 @@ int grasbw_cbBWRequest(gras_msg_t *msg) {
  * Link saturation
  * ***************************************************************************/
 
-gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
+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;
-  gras_error_t errcode;
+  xbt_error_t errcode;
   /* The request */
   SatExp_t *request;
   msgHost_t *target;
@@ -369,7 +378,7 @@ gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
 
   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__,gras_error_name(errcode));
+           __FILE__,__LINE__,xbt_error_name(errcode));
     return errcode;
   }
   if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t))) ||
@@ -389,20 +398,20 @@ gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
                              target,1,
                              request,1))) {
     fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while sending the request.\n",
-           __FILE__,__LINE__,gras_error_name(errcode));
+           __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__,gras_error_name(errcode));
+           __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__,gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+           __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;
@@ -416,7 +425,7 @@ gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
 int grasbw_cbSatStart(gras_msg_t *msg) {
   gras_rawsock_t *raw;
   gras_sock_t *sock;
-  gras_error_t errcode;
+  xbt_error_t errcode;
   double start; /* time to timeout */
 
   /* specification of the test to run */
@@ -442,7 +451,7 @@ int grasbw_cbSatStart(gras_msg_t *msg) {
   /* Negociate the saturation with the peer */
   if((errcode=gras_sock_client_open(to_name,to_port,&sock))) {
     fprintf(stderr,"cbSatStart(): Error %s encountered while contacting peer\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
                     "cbSatStart: Severe error: Cannot send error status to requester!!\n",
                     errcode,"Cannot contact peer.\n");
@@ -463,7 +472,7 @@ int grasbw_cbSatStart(gras_msg_t *msg) {
   if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_BEGIN, 1, 
                              request,1))) {
     fprintf(stderr,"cbSatStart(): Error %s encountered while sending the request.\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
                     "cbSatStart: Severe error: Cannot send error status to requester!!\n",
                     errcode,"Cannot send request.\n");
@@ -473,7 +482,7 @@ int grasbw_cbSatStart(gras_msg_t *msg) {
 
   if ((errcode=gras_msg_wait(120,GRASMSG_SAT_BEGUN,&answer))) {
     fprintf(stderr,"cbSatStart(): Error %s encountered while waiting for the ACK.\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_sock_close(sock);
 
     grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
@@ -485,7 +494,7 @@ int grasbw_cbSatStart(gras_msg_t *msg) {
 
   if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
     fprintf(stderr,"cbSatStart(): Peer reported error %s (%s).\n",
-           gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+           xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
 
     grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
                     "cbSatStart: Severe error: Cannot send error status to requester!!\n",
@@ -500,7 +509,7 @@ int grasbw_cbSatStart(gras_msg_t *msg) {
 
   if ((errcode=gras_rawsock_client_open(to_name,raw_port,msgSize,&raw))) {
     fprintf(stderr,"cbSatStart(): Error %s while opening raw socket to %s:%d.\n",
-           gras_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
+           xbt_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
 
     grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
                     "cbSatStart: Severe error: Cannot send error status to requester!!\n",
@@ -511,7 +520,7 @@ int grasbw_cbSatStart(gras_msg_t *msg) {
 
   /* send a train of data before repporting that XP is started */
   if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
-    fprintf(stderr,"cbSatStart: Failure %s during raw send\n",gras_error_name(errcode));
+    fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
     grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
                     "cbSatStart: Severe error: Cannot send error status to requester!!\n",
                     errcode,"Cannot raw send.\n");
@@ -531,7 +540,7 @@ int grasbw_cbSatStart(gras_msg_t *msg) {
   while (gras_msg_wait(0,GRASMSG_SAT_STOP,&msg)==timeout_error && 
         gras_time()-start < timeout) {
     if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
-      fprintf(stderr,"cbSatStart: Failure %s during raw send\n",gras_error_name(errcode));
+      fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
       /* our error message do not interess anyone. SAT_STOP will do nothing. */
       gras_sock_close(sock);
       gras_rawsock_close(raw);
@@ -582,7 +591,7 @@ int grasbw_cbSatStart(gras_msg_t *msg) {
 
 int grasbw_cbSatBegin(gras_msg_t *msg) {
   gras_rawsock_t *raw;
-  gras_error_t errcode;
+  xbt_error_t errcode;
   double start; /* timer */
   /* request */
   unsigned int msgSize=gras_msg_ctn(msg,0,0,SatExp_t).msgSize;
@@ -602,7 +611,7 @@ int grasbw_cbSatBegin(gras_msg_t *msg) {
 
   if ((errcode=gras_rawsock_server_open(6666,8000,msgSize,&raw))) { 
     fprintf(stderr,"cbSatBegin(): Error %s encountered while opening a raw socket\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     grasRepportError(msg->sock,GRASMSG_SAT_BEGUN,2,
                     "cbSatBegin: Severe error: Cannot send error status to requester!!\n",
                     errcode,"Cannot open raw socket");
@@ -616,7 +625,7 @@ int grasbw_cbSatBegin(gras_msg_t *msg) {
                              error,1,
                              request,1))) {
     fprintf(stderr,"cbSatBegin(): Error %s encountered while send ACK to peer\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     return 1;
   }
   gras_msg_free(msg);
@@ -626,7 +635,7 @@ int grasbw_cbSatBegin(gras_msg_t *msg) {
         gras_time() - start < timeout) {
     errcode=gras_rawsock_recv(raw,msgSize,msgSize,1);
     if (errcode != timeout_error && errcode != no_error) {
-      fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",gras_error_name(errcode));
+      fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",xbt_error_name(errcode));
       /* our error message do not interess anyone. SAT_END will do nothing. */
       /* (if timeout'ed, it may be because the sender stopped emission. so survive it) */
       return 1;
@@ -646,35 +655,35 @@ int grasbw_cbSatBegin(gras_msg_t *msg) {
   return 1;
 }
 
-gras_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
                                 const char* to_name,unsigned int to_port) {
-  gras_error_t errcode;
+  xbt_error_t errcode;
   gras_sock_t *sock;
   gras_msg_t *answer;
 
   if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
     fprintf(stderr,"saturate_stop(): Error %s encountered while contacting peer\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     return errcode;
   }
 
   if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_STOP,0))) {
     fprintf(stderr,"saturate_stop(): Error %s encountered while sending request\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_sock_close(sock);
     return errcode;
   }
 
   if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STOPPED,&answer))) {
     fprintf(stderr,"saturate_stop(): Error %s encountered while receiving ACK\n",
-           gras_error_name(errcode));
+           xbt_error_name(errcode));
     gras_sock_close(sock);
     return errcode;
   }
 
   if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
     fprintf(stderr,"saturate_stop(): Peer reported error %s (%s).\n",
-           gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+           xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
     gras_msg_free(answer);
     gras_sock_close(sock);
     return errcode;
@@ -685,3 +694,4 @@ gras_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
 
   return no_error;
 }
+#endif