+ CATCH_ANONYMOUS {
+ RETHROWF
+ ("Error encountered while opening the measurement socket to %s:%d for BW test: %s",
+ xbt_socket_peer_name(peer), request_ack->peer.port);
+ }
+ XBT_DEBUG
+ ("Got ACK; conduct the experiment (msg_size = %lu, msg_amount=%lu)",
+ request->msg_size, request->msg_amount);
+
+ *sec = 0;
+ first_pass = 1;
+ do {
+ if (first_pass == 0) {
+ double meas_duration = *sec;
+ double increase;
+ if (*sec != 0.0) {
+ increase = (min_duration / meas_duration) * 1.1;
+ } else {
+ increase = 4;
+ }
+ /* Do not increase the exp size too fast since our decision would be based on wrong measurements */
+ if (increase > 20)
+ increase = 20;
+
+ request->msg_size = request->msg_size * increase;
+
+ /* Do not do too large experiments messages or the sensors
+ will start to swap to store one of them.
+ And then increase the number of messages to compensate (check for overflow there, too) */
+ if (request->msg_size > 64 * 1024 * 1024) {
+ unsigned long int new_amount =
+ ((request->msg_size / ((double) 64 * 1024 * 1024))
+ * request->msg_amount) + 1;
+
+ xbt_assert(new_amount > request->msg_amount,
+ "Overflow on the number of messages! You must have a *really* fat pipe. Please fix your platform");
+ request->msg_amount = new_amount;
+
+ request->msg_size = 64 * 1024 * 1024;
+ }
+
+ XBT_VERB
+ ("The experiment was too short (%f sec<%f sec). Redo it with msg_size=%lu (nb_messages=%lu) (got %fMb/s)",
+ meas_duration, min_duration, request->msg_size,
+ request->msg_amount,
+ ((double) request->msg_size) * ((double) request->msg_amount /
+ (*sec) / 1024.0 / 1024.0));
+
+ gras_msg_rpccall(peer, 60, "BW reask", &request, NULL);
+ }
+
+ first_pass = 0;
+ *sec = gras_os_time();
+ TRY {
+ xbt_socket_meas_send(measOut, 120, request->msg_size,
+ request->msg_amount);
+ XBT_DEBUG("Data sent. Wait ACK");
+ xbt_socket_meas_recv(measIn, 120, 1, 1);
+ }
+ CATCH_ANONYMOUS {
+ gras_socket_close(measOut);
+ gras_socket_close(measMasterIn);
+ gras_socket_close(measIn);
+ RETHROWF("Unable to conduct the experiment: %s");
+ }
+ *sec = gras_os_time() - *sec;
+ if (*sec != 0.0) {
+ *bw =
+ ((double) request->msg_size) * ((double) request->msg_amount) /
+ (*sec);
+ }
+ XBT_DEBUG("Experiment done ; it took %f sec", *sec);
+ if (*sec <= 0) {
+ XBT_CRITICAL("Nonpositive value (%f) found for BW test time.", *sec);
+ }
+
+ } while (*sec < min_duration);