mysock = gras_socket_server_range(3000,9999,0,0);
INFO1("Sensor starting (on port %d)",gras_os_myport());
mysock = gras_socket_server_range(3000,9999,0,0);
INFO1("Sensor starting (on port %d)",gras_os_myport());
- gras_os_sleep(0.5); /* let the master get ready */
- master = gras_socket_client_from_string(argv[1]);
+ while (connection_try > 0 && master == NULL) {
+ int connected = 0;
+ TRY {
+ master = gras_socket_client_from_string(argv[1]);
+ connected = 1;
+ } CATCH(e) {
+ xbt_ex_free(e);
+ }
+ if (!connected) {
+ connection_try--;
+ gras_os_sleep(0.5); /* let the master get ready */
+ }
+ }
INFO0("Wait for peers for 5 sec");
gras_msg_handleall(5); /* friends, we're ready. Come and play */
INFO0("Wait for peers for 5 sec");
gras_msg_handleall(5); /* friends, we're ready. Come and play */
char *msg;
asprintf(&msg,"Not enough peers arrived. Expected 2 got %ld",
xbt_dynar_length(group));
char *msg;
asprintf(&msg,"Not enough peers arrived. Expected 2 got %ld",
xbt_dynar_length(group));
- h1 = *(xbt_host_t*) xbt_dynar_get_ptr(group, 0);
- h2 = *(xbt_host_t*)xbt_dynar_get_ptr(group, 1);
+ h1 = *(xbt_peer_t*)xbt_dynar_get_ptr(group, 0);
+ h2 = *(xbt_peer_t*)xbt_dynar_get_ptr(group, 1);
+ /* sort peers in right order to keep output right */
+ if (strcmp(h1->name,h2->name) < 0 || h1->port > h2->port) {
+ h_temp = h1;
+ h1 = h2;
+ h2 = h_temp;
+ }
INFO2("Contact %s:%d",h1->name, h1->port);
peer = gras_socket_client(h1->name, h1->port);
INFO0("Test the BW between me and one of the sensors");
INFO2("Contact %s:%d",h1->name, h1->port);
peer = gras_socket_client(h1->name, h1->port);
INFO0("Test the BW between me and one of the sensors");
- amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
- INFO6("Experience between me and %s:%d (%d bytes in msgs of %d bytes) took %f sec, achieving %f kb/s",
+ amok_bw_test(peer,buf_size,msg_size,msg_amount,min_duration,&sec,&bw);
+ INFO7("Experience between me and %s:%d (initially %d msgs of %d bytes, maybe modified to fill the pipe at least %.1fs) took %f sec, achieving %f kb/s",
sec,((double)bw)/1024.0);
INFO4("Test the BW between %s:%d and %s:%d", h1->name, h1->port, h2->name, h2->port);
amok_bw_request(h1->name, h1->port, h2->name, h2->port,
sec,((double)bw)/1024.0);
INFO4("Test the BW between %s:%d and %s:%d", h1->name, h1->port, h2->name, h2->port);
amok_bw_request(h1->name, h1->port, h2->name, h2->port,
- buf_size,exp_size,msg_size,min_duration,&sec,&bw);
+ buf_size,msg_size,msg_amount,min_duration,&sec,&bw);
INFO6("Experience between %s:%d and %s:%d took took %f sec, achieving %f kb/s",
h1->name, h1->port, h2->name, h2->port,
sec,((double)bw)/1024.0);
/* Game is over, friends */
INFO6("Experience between %s:%d and %s:%d took took %f sec, achieving %f kb/s",
h1->name, h1->port, h2->name, h2->port,
sec,((double)bw)/1024.0);
/* Game is over, friends */