3 /* saturate - link saturation demo of AMOK features */
5 /* Copyright (c) 2003-6 Martin Quinson. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
16 #include "amok/bandwidth.h"
17 #include "amok/hostmanagement.h"
19 XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
21 static void env_hosttohost_bw(int argc, char*argv[]) {
23 /* where are the sensors */
24 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
34 gras_socket_t peer; /* socket to sensor */
36 /* wait to ensure that all server sockets are there before starting the experiment */
39 /* Get the sensor location from argc/argv */
40 for (i=1; i<argc-1; i+=2){
41 xbt_host_t host=xbt_new(s_xbt_host_t,1);
42 host->name=strdup(argv[i]);
43 host->port=atoi(argv[i+1]);
44 INFO2("New sensor: %s:%d",host->name,host->port);
45 xbt_dynar_push(hosts,&host);
47 nb_hosts = xbt_dynar_length(hosts);
49 INFO0(">>> start Test1: ENV end to end mesurements");
51 xbt_dynar_foreach(hosts,i,h1) {
52 peer = gras_socket_client(h1->name,h1->port);
53 amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
54 INFO6("Bandwidth between me and %s:%d (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
57 sec,((double)bw)/1024.0);
60 xbt_dynar_map(hosts,kill_buddy_dynar);
61 xbt_dynar_free(&hosts);
64 /********************************************************************************************/
65 static void env_Pairwisehost_bw(int argc, char*argv[]) {
68 /* where are the sensors */
69 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
72 /* getting the name of maestro for the saturation and the concurrent bandwidth measurements */
73 char* host_test=argv[0];
82 /* socket to sensor */
85 /* wait to ensure that all server sockets are there before starting the experiment */
88 INFO1(">>>>>< le maestro est: %s ",argv[0]);
89 /* Get the sensor location from argc/argv */
90 for (i=1; i<argc-1; i+=2){
91 xbt_host_t host=xbt_new(s_xbt_host_t,1);
92 host->name=strdup(argv[i]);
93 host->port=atoi(argv[i+1]);
94 INFO2("New sensor: %s:%d",host->name,host->port);
95 xbt_dynar_push(hosts,&host);
97 nb_hosts = xbt_dynar_length(hosts);
99 INFO0(">>> start Test2: ENV pairwise host bandwidth mesurements");
100 xbt_dynar_foreach(hosts,i,h1) {
103 amok_bw_saturate_start(h1->name,h1->port,
104 host_test,h1->port,//"Ginette"
105 msg_size,120); // sturation of the link with msg_size to compute a concurent bandwidth MA //MB
107 RETHROW0("Cannot ask hosts to saturate the link: %s");
109 // gras_os_sleep(1.0);
111 xbt_dynar_foreach(hosts,j,h2) {
114 peer = gras_socket_client(h2->name,h2->port);
115 amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
116 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",
119 sec,((double)bw)/1024.0);
122 amok_bw_saturate_stop(h1->name,h1->port,NULL,NULL);
124 xbt_dynar_map(hosts,kill_buddy_dynar);
125 xbt_dynar_free(&hosts);
129 int maestro(int argc,char *argv[]) {
131 gras_init(&argc,argv);
135 gras_socket_server(3333); /* only so that messages from the transport layer in gras identify us */
137 //env_Pairwisehost_bw(argc,argv);
138 //env_hosttohost_bw(argc,argv);