+ /* where are the sensors */
+ xbt_dynar_t peers;
+ xbt_peer_t h1, h2;
+ /* results */
+ double duration, bw;
+
+ /* Init the group */
+ peers = amok_pm_group_new("saturate");
+ /* wait for dudes */
+ gras_msg_handleall(5);
+
+ /* Stop all sensors but two of them */
+ while (xbt_dynar_length(peers) > 2) {
+ xbt_dynar_pop(peers, &h1);
+ amok_pm_kill_hp(h1->name, h1->port);
+ xbt_peer_free(h1);
+ }
+
+ /* get 2 friends */
+ xbt_dynar_get_cpy(peers, 0, &h1);
+ xbt_dynar_get_cpy(peers, 1, &h2);
+
+ /* Start saturation */
+ XBT_INFO("Start saturation between %s:%d and %s:%d",
+ h1->name, h1->port, h2->name, h2->port);
+
+ amok_bw_saturate_start(h1->name, h1->port, h2->name, h2->port, 0, /* Be a nice boy, compute msg_size yourself */
+ 30 /* 5 sec timeout */ );
+
+ /* Stop it after a while */
+ XBT_INFO("Have a rest");
+ gras_os_sleep(1);
+ TRY {
+ XBT_INFO("Stop the saturation");
+ amok_bw_saturate_stop(h1->name, h1->port, &duration, &bw);
+ }
+ CATCH(e) {
+ XBT_INFO("Ooops, stoping the saturation raised an exception");
+ xbt_ex_free(e);
+ }
+ XBT_INFO("Saturation took %.2fsec, achieving %fb/s", duration, bw);
+
+ /* Game is over, friends */
+ amok_pm_group_shutdown("saturate");
+}
+
+/********************************************************************************************/
+static void full_fledged_saturation(int argc, char *argv[])
+{
+ double time1 = 5.0, bw1 = 5.0; // 0.5 for test