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,
19 "Messages specific to this example");
21 static void env_hosttohost_bw(int argc, char *argv[])
24 /* where are the sensors */
25 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t), &free_host);
35 gras_socket_t peer; /* socket to sensor */
37 /* wait to ensure that all server sockets are there before starting the experiment */
40 /* Get the sensor location from argc/argv */
41 for (i = 1; i < argc - 1; i += 2) {
42 xbt_host_t host = xbt_new(s_xbt_host_t, 1);
43 host->name = strdup(argv[i]);
44 host->port = atoi(argv[i + 1]);
45 INFO2("New sensor: %s:%d", host->name, host->port);
46 xbt_dynar_push(hosts, &host);
48 nb_hosts = xbt_dynar_length(hosts);
50 INFO0(">>> start Test1: ENV end to end mesurements");
52 xbt_dynar_foreach(hosts, i, h1) {
53 peer = gras_socket_client(h1->name, h1->port);
54 amok_bw_test(peer, buf_size, exp_size, msg_size, min_duration, &sec,
57 ("Bandwidth between me and %s:%d (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
58 h1->name, h1->port, exp_size, msg_size, sec,
59 ((double) bw) / 1024.0);
62 xbt_dynar_map(hosts, kill_buddy_dynar);
63 xbt_dynar_free(&hosts);
67 /********************************************************************************************/
68 static void env_Pairwisehost_bw(int argc, char *argv[])
72 /* where are the sensors */
73 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t), &free_host);
76 /* getting the name of maestro for the saturation and the concurrent bandwidth measurements */
77 char *host_test = argv[0];
86 /* socket to sensor */
89 /* wait to ensure that all server sockets are there before starting the experiment */
92 INFO1(">>>>>< le maestro est: %s ", argv[0]);
93 /* Get the sensor location from argc/argv */
94 for (i = 1; i < argc - 1; i += 2) {
95 xbt_host_t host = xbt_new(s_xbt_host_t, 1);
96 host->name = strdup(argv[i]);
97 host->port = atoi(argv[i + 1]);
98 INFO2("New sensor: %s:%d", host->name, host->port);
99 xbt_dynar_push(hosts, &host);
101 nb_hosts = xbt_dynar_length(hosts);
103 INFO0(">>> start Test2: ENV pairwise host bandwidth mesurements");
104 xbt_dynar_foreach(hosts, i, h1) {
107 amok_bw_saturate_start(h1->name, h1->port, host_test, h1->port, //"Ginette"
108 msg_size, 120); // sturation of the link with msg_size to compute a concurent bandwidth MA //MB
111 RETHROW0("Cannot ask hosts to saturate the link: %s");
113 // gras_os_sleep(1.0);
115 xbt_dynar_foreach(hosts, j, h2) {
119 peer = gras_socket_client(h2->name, h2->port);
120 amok_bw_test(peer, buf_size, exp_size, msg_size, min_duration, &sec,
123 ("Bandwidth between me and %s // measurement between me and %s (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
124 h2->name, h1->name, exp_size, msg_size, sec,
125 ((double) bw) / 1024.0);
128 amok_bw_saturate_stop(h1->name, h1->port, NULL, NULL);
130 xbt_dynar_map(hosts, kill_buddy_dynar);
131 xbt_dynar_free(&hosts);
135 int maestro(int argc, char *argv[])
138 gras_init(&argc, argv);
142 gras_socket_server(3333); /* only so that messages from the transport layer in gras identify us */
144 //env_Pairwisehost_bw(argc,argv);
145 //env_hosttohost_bw(argc,argv);