#include "amok/Bandwidth/bandwidth_private.h"
#include "gras/Msg/msg_private.h" /* FIXME: This mucks with contextes to answer RPC directly */
-XBT_LOG_EXTERNAL_CATEGORY(amok_bw);
-XBT_LOG_DEFAULT_CATEGORY(amok_bw);
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(amok_bw_sat,amok_bw,"Everything concerning the SATuration part of the amok_bw module");
static int amok_bw_cb_sat_start(gras_msg_cb_ctx_t ctx, void *payload);
static int amok_bw_cb_sat_begin(gras_msg_cb_ctx_t ctx, void *payload);
* is to have a remote host calling amok_bw_saturate_stop to this process.
*
* If duration=0, the experiment will never timeout (you then have to manually
- * stop it)
+ * stop it).
+ *
+ * If msg_size=0, the size will be automatically computed to make sure that
+ * each of the messages occupy the connexion one second
*/
void amok_bw_saturate_begin(const char* to_name,unsigned int to_port,
unsigned int msg_size, double duration,
request->host.name = NULL;
request->host.port = 0;
+ /* Size autodetection on need */
+ if (!msg_size) {
+ double bw;
+ double sec;
+ amok_bw_test(peer_cmd,
+ 0,512*1024, 512*1024, /* 512k as first guess */
+ 1, /* at least one sec */
+ &sec, &bw);
+ request->msg_size = (int)bw;
+ }
+
+ /* Launch the saturation */
ctx = gras_msg_rpc_async_call(peer_cmd, 60,
gras_msgtype_by_name("amok_bw_sat begin"),
&request);
free(request);
gras_socket_close(peer_cmd);
- INFO2("Saturation from %s to %s started",gras_os_myname(),to_name);
+ INFO2("Saturation(%s->%s) started",gras_os_myname(),to_name);
/* Start experiment */
start=gras_os_time();
/* Check whether the experiment has to be terminated by now */
elapsed=gras_os_time()-start;
- VERB2("elapsed %f duration %f",elapsed, duration);
+ DEBUG2("elapsed %f duration %f",elapsed, duration);
} while (saturate_further && (duration==0 || elapsed < duration));
volatile int saturate_further = 1;
xbt_ex_t e;
gras_socket_t measMaster=NULL,meas=NULL;
+ gras_socket_t from=gras_msg_cb_ctx_from(ctx);
int port=6000;
while (port <= 10000 && measMaster == NULL) {
while (saturate_further) {
TRY {
- gras_socket_meas_recv(meas,120,request->msg_size,request->msg_size);
+ gras_socket_meas_recv(meas,5,request->msg_size,request->msg_size);
} CATCH(e) {
saturate_further = 0;
xbt_ex_free(e);
}
}
- INFO1("Saturation stopped on %s",gras_os_myname());
+ INFO3("Saturation comming from %s:%d stopped on %s",
+ gras_socket_peer_name(from),gras_socket_peer_port(from),
+ gras_os_myname());
+
gras_socket_close(meas);
if (gras_if_RL()) /* On SG, accepted=master */
gras_socket_close(measMaster);
*/
void amok_bw_saturate_stop(const char* from_name,unsigned int from_port,
/*out*/ double *time, double *bw) {
-
+ xbt_ex_t e;
+
gras_socket_t sock = gras_socket_client(from_name,from_port);
bw_res_t answer;
- VERB2("Ask %s:%d to stop the saturation",
- from_name,from_port);
- gras_msg_rpccall(sock,60,gras_msgtype_by_name("amok_bw_sat stop"),NULL,&answer);
+ VERB2("Ask %s:%d to stop the saturation",from_name,from_port);
+ TRY {
+ gras_msg_rpccall(sock,60,gras_msgtype_by_name("amok_bw_sat stop"),NULL,&answer);
+ } CATCH(e) {
+ RETHROW2("Cannot ask %s:%d to stop saturation: %s",from_name, from_port);
+ }
gras_socket_close(sock);
if (time) *time=answer->sec;
if (bw) *bw =answer->bw;
+ free(answer);
}