1 /* saturate - link saturation demo of AMOK features */
3 /* Copyright (c) 2003-6 Martin Quinson. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
14 #include "amok/bandwidth.h"
15 #include "amok/hostmanagement.h"
17 XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
19 static void env_hosttohost_bw(int argc, char*argv[]) {
21 /* where are the sensors */
22 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
32 gras_socket_t peer; /* socket to sensor */
34 /* wait to ensure that all server sockets are there before starting the experiment */
37 /* Get the sensor location from argc/argv */
38 for (i=1; i<argc-1; i+=2){
39 xbt_host_t host=xbt_new(s_xbt_host_t,1);
40 host->name=strdup(argv[i]);
41 host->port=atoi(argv[i+1]);
42 INFO2("New sensor: %s:%d",host->name,host->port);
43 xbt_dynar_push(hosts,&host);
45 nb_hosts = xbt_dynar_length(hosts);
47 INFO0(">>> start Test1: ENV end to end mesurements");
49 xbt_dynar_foreach(hosts,i,h1) {
50 peer = gras_socket_client(h1->name,h1->port);
51 amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
52 INFO6("Bandwidth between me and %s:%d (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
55 sec,((double)bw)/1024.0);
58 xbt_dynar_map(hosts,kill_buddy_dynar);
59 xbt_dynar_free(&hosts);
62 /********************************************************************************************/
63 static void env_Pairwisehost_bw(int argc, char*argv[]) {
66 /* where are the sensors */
67 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
70 /* getting the name of maestro for the saturation and the concurrent bandwidth measurements */
71 char* host_test=argv[0];
80 /* socket to sensor */
83 /* wait to ensure that all server sockets are there before starting the experiment */
86 INFO1(">>>>>< le maestro est: %s ",argv[0]);
87 /* Get the sensor location from argc/argv */
88 for (i=1; i<argc-1; i+=2){
89 xbt_host_t host=xbt_new(s_xbt_host_t,1);
90 host->name=strdup(argv[i]);
91 host->port=atoi(argv[i+1]);
92 INFO2("New sensor: %s:%d",host->name,host->port);
93 xbt_dynar_push(hosts,&host);
95 nb_hosts = xbt_dynar_length(hosts);
97 INFO0(">>> start Test2: ENV pairwise host bandwidth mesurements");
98 xbt_dynar_foreach(hosts,i,h1) {
101 amok_bw_saturate_start(h1->name,h1->port,
102 host_test,h1->port,//"Ginette"
103 msg_size,120); // sturation of the link with msg_size to compute a concurent bandwidth MA //MB
105 RETHROW0("Cannot ask hosts to saturate the link: %s");
107 // gras_os_sleep(1.0);
109 xbt_dynar_foreach(hosts,j,h2) {
112 peer = gras_socket_client(h2->name,h2->port);
113 amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
114 INFO6("Bandwidth between me and %s // measurement between me and %s (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
117 sec,((double)bw)/1024.0);
120 amok_bw_saturate_stop(h1->name,h1->port,NULL,NULL);
122 xbt_dynar_map(hosts,kill_buddy_dynar);
123 xbt_dynar_free(&hosts);
127 int maestro(int argc,char *argv[]) {
129 gras_init(&argc,argv);
133 gras_socket_server(3333); /* only so that messages from the transport layer in gras identify us */
135 //env_Pairwisehost_bw(argc,argv);
136 //env_hosttohost_bw(argc,argv);