1 /* saturate - link saturation demo of AMOK features */
3 /* Copyright (c) 2006, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
15 #include "amok/bandwidth.h"
16 #include "amok/hostmanagement.h"
18 XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
20 static void env_hosttohost_bw(int argc, char*argv[]) {
22 /* where are the sensors */
23 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
33 gras_socket_t peer; /* socket to sensor */
35 /* wait to ensure that all server sockets are there before starting the experiment */
38 /* Get the sensor location from argc/argv */
39 for (i=1; i<argc-1; i+=2){
40 xbt_host_t host=xbt_new(s_xbt_host_t,1);
41 host->name=strdup(argv[i]);
42 host->port=atoi(argv[i+1]);
43 INFO2("New sensor: %s:%d",host->name,host->port);
44 xbt_dynar_push(hosts,&host);
46 nb_hosts = xbt_dynar_length(hosts);
48 INFO0(">>> start Test1: ENV end to end mesurements");
50 xbt_dynar_foreach(hosts,i,h1) {
51 peer = gras_socket_client(h1->name,h1->port);
52 amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
53 INFO6("Bandwidth between me and %s:%d (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
56 sec,((double)bw)/1024.0);
59 xbt_dynar_map(hosts,kill_buddy_dynar);
60 xbt_dynar_free(&hosts);
63 /********************************************************************************************/
64 static void env_Pairwisehost_bw(int argc, char*argv[]) {
67 /* where are the sensors */
68 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
71 /* getting the name of maestro for the saturation and the concurrent bandwidth measurements */
72 char* host_test=argv[0];
81 /* socket to sensor */
84 /* wait to ensure that all server sockets are there before starting the experiment */
87 INFO1(">>>>>< le maestro est: %s ",argv[0]);
88 /* Get the sensor location from argc/argv */
89 for (i=1; i<argc-1; i+=2){
90 xbt_host_t host=xbt_new(s_xbt_host_t,1);
91 host->name=strdup(argv[i]);
92 host->port=atoi(argv[i+1]);
93 INFO2("New sensor: %s:%d",host->name,host->port);
94 xbt_dynar_push(hosts,&host);
96 nb_hosts = xbt_dynar_length(hosts);
98 INFO0(">>> start Test2: ENV pairwise host bandwidth mesurements");
99 xbt_dynar_foreach(hosts,i,h1) {
102 amok_bw_saturate_start(h1->name,h1->port,
103 host_test,h1->port,//"Ginette"
104 msg_size,120); // sturation of the link with msg_size to compute a concurent bandwidth MA //MB
106 RETHROW0("Cannot ask hosts to saturate the link: %s");
108 // gras_os_sleep(1.0);
110 xbt_dynar_foreach(hosts,j,h2) {
113 peer = gras_socket_client(h2->name,h2->port);
114 amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
115 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",
118 sec,((double)bw)/1024.0);
121 amok_bw_saturate_stop(h1->name,h1->port,NULL,NULL);
123 xbt_dynar_map(hosts,kill_buddy_dynar);
124 xbt_dynar_free(&hosts);
128 int maestro(int argc,char *argv[]) {
130 gras_init(&argc,argv);
134 gras_socket_server(3333); /* only so that messages from the transport layer in gras identify us */
136 //env_Pairwisehost_bw(argc,argv);
137 //env_hosttohost_bw(argc,argv);