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 xbt_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 XBT_INFO("New sensor: %s:%d", host->name, host->port);
46 xbt_dynar_push(hosts, &host);
48 nb_hosts = xbt_dynar_length(hosts);
50 XBT_INFO(">>> 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[])
70 /* where are the sensors */
71 xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t), &free_host);
74 /* getting the name of maestro for the saturation and the concurrent bandwidth measurements */
75 char *host_test = argv[0];
84 /* socket to sensor */
87 /* wait to ensure that all server sockets are there before starting the experiment */
90 XBT_INFO(">>>>>< le maestro est: %s ", argv[0]);
91 /* Get the sensor location from argc/argv */
92 for (i = 1; i < argc - 1; i += 2) {
93 xbt_host_t host = xbt_new(s_xbt_host_t, 1);
94 host->name = strdup(argv[i]);
95 host->port = atoi(argv[i + 1]);
96 XBT_INFO("New sensor: %s:%d", host->name, host->port);
97 xbt_dynar_push(hosts, &host);
99 nb_hosts = xbt_dynar_length(hosts);
101 XBT_INFO(">>> start Test2: ENV pairwise host bandwidth mesurements");
102 xbt_dynar_foreach(hosts, i, h1) {
105 amok_bw_saturate_start(h1->name, h1->port, host_test, h1->port, //"Ginette"
106 msg_size, 120); // sturation of the link with msg_size to compute a concurent bandwidth MA //MB
109 RETHROWF("Cannot ask hosts to saturate the link: %s");
111 // gras_os_sleep(1.0);
113 xbt_dynar_foreach(hosts, j, h2) {
117 peer = gras_socket_client(h2->name, h2->port);
118 amok_bw_test(peer, buf_size, exp_size, msg_size, min_duration, &sec,
121 ("Bandwidth between me and %s // measurement between me and %s (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
122 h2->name, h1->name, exp_size, msg_size, sec,
123 ((double) bw) / 1024.0);
126 amok_bw_saturate_stop(h1->name, h1->port, NULL, NULL);
128 xbt_dynar_map(hosts, kill_buddy_dynar);
129 xbt_dynar_free(&hosts);
133 int maestro(int argc, char *argv[])
136 gras_init(&argc, argv);
140 gras_socket_server(3333); /* only so that messages from the transport layer in gras identify us */
142 //env_Pairwisehost_bw(argc,argv);
143 //env_hosttohost_bw(argc,argv);