diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-23 12:28:32 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-23 12:28:32 +0000 |
commit | 74e92716b7dd1e117cb8ef932348335c98daa0e1 (patch) | |
tree | fdd8133d903f337b6e0d3c8f67965cd8bf2f4a46 | |
parent | d3ce95bec0495962ad80d3eba9b5e11e09a2b25d (diff) | |
download | gnunet-74e92716b7dd1e117cb8ef932348335c98daa0e1.tar.gz gnunet-74e92716b7dd1e117cb8ef932348335c98daa0e1.zip |
experimentation basics
-rw-r--r-- | src/ats-tests/Makefile.am | 3 | ||||
-rw-r--r-- | src/ats-tests/ats-testing-experiment.c | 130 | ||||
-rw-r--r-- | src/ats-tests/ats-testing-traffic.c | 16 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.h | 15 | ||||
-rw-r--r-- | src/ats-tests/gnunet-ats-sim.c | 44 |
5 files changed, 182 insertions, 26 deletions
diff --git a/src/ats-tests/Makefile.am b/src/ats-tests/Makefile.am index 5753abea1..60cb85c93 100644 --- a/src/ats-tests/Makefile.am +++ b/src/ats-tests/Makefile.am | |||
@@ -52,7 +52,8 @@ noinst_PROGRAMS = \ | |||
52 | gnunet-ats-sim | 52 | gnunet-ats-sim |
53 | 53 | ||
54 | libgnunetatstesting_la_SOURCES = \ | 54 | libgnunetatstesting_la_SOURCES = \ |
55 | ats-testing.c ats-testing-log.c ats-testing-traffic.c ats-testing.h | 55 | ats-testing.c ats-testing-log.c ats-testing-traffic.c \ |
56 | ats-testing-experiment.c | ||
56 | libgnunetatstesting_la_LIBADD = \ | 57 | libgnunetatstesting_la_LIBADD = \ |
57 | $(top_builddir)/src/transport/libgnunettransport.la \ | 58 | $(top_builddir)/src/transport/libgnunettransport.la \ |
58 | $(top_builddir)/src/hello/libgnunethello.la \ | 59 | $(top_builddir)/src/hello/libgnunethello.la \ |
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c new file mode 100644 index 000000000..d0e74d1c3 --- /dev/null +++ b/src/ats-tests/ats-testing-experiment.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010-2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/ats-testing-experiment.c | ||
22 | * @brief ats benchmark: controlled experiment execution | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "ats-testing.h" | ||
29 | |||
30 | static struct Experiment * | ||
31 | create_experiment () | ||
32 | { | ||
33 | struct Experiment *e; | ||
34 | e = GNUNET_new (struct Experiment); | ||
35 | e->name = NULL; | ||
36 | e->num_masters = 0; | ||
37 | e->num_slaves = 0; | ||
38 | |||
39 | return e; | ||
40 | } | ||
41 | |||
42 | static void | ||
43 | free_experiment (struct Experiment *e) | ||
44 | { | ||
45 | GNUNET_free_non_null (e->name); | ||
46 | GNUNET_free_non_null (e->cfg_file); | ||
47 | GNUNET_free (e); | ||
48 | } | ||
49 | |||
50 | struct Experiment * | ||
51 | GNUNET_ATS_TEST_experimentation_start (char *filename) | ||
52 | { | ||
53 | struct Experiment *e; | ||
54 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
55 | e = NULL; | ||
56 | |||
57 | cfg = GNUNET_CONFIGURATION_create(); | ||
58 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename)) | ||
59 | { | ||
60 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to load `%s'\n", filename); | ||
61 | GNUNET_CONFIGURATION_destroy (cfg); | ||
62 | return NULL; | ||
63 | } | ||
64 | |||
65 | e = create_experiment (); | ||
66 | |||
67 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", | ||
68 | "name", &e->name)) | ||
69 | { | ||
70 | fprintf (stderr, "Invalid %s", "name"); | ||
71 | free_experiment (e); | ||
72 | return NULL; | ||
73 | } | ||
74 | else | ||
75 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name); | ||
76 | |||
77 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment", | ||
78 | "cfg_file", &e->cfg_file)) | ||
79 | { | ||
80 | fprintf (stderr, "Invalid %s", "cfg_file"); | ||
81 | free_experiment (e); | ||
82 | return NULL; | ||
83 | } | ||
84 | else | ||
85 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->cfg_file); | ||
86 | |||
87 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | ||
88 | "masters", &e->num_masters)) | ||
89 | { | ||
90 | fprintf (stderr, "Invalid %s", "masters"); | ||
91 | free_experiment (e); | ||
92 | return NULL; | ||
93 | } | ||
94 | else | ||
95 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment masters: `%llu'\n", | ||
96 | e->num_masters); | ||
97 | |||
98 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | ||
99 | "slaves", &e->num_slaves)) | ||
100 | { | ||
101 | fprintf (stderr, "Invalid %s", "slaves"); | ||
102 | free_experiment (e); | ||
103 | return NULL; | ||
104 | } | ||
105 | else | ||
106 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment slaves: `%llu'\n", | ||
107 | e->num_slaves); | ||
108 | |||
109 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", | ||
110 | "max_duration", &e->max_duration)) | ||
111 | { | ||
112 | fprintf (stderr, "Invalid %s", "max_duration"); | ||
113 | free_experiment (e); | ||
114 | return NULL; | ||
115 | } | ||
116 | else | ||
117 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n", | ||
118 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES)); | ||
119 | |||
120 | return e; | ||
121 | } | ||
122 | |||
123 | void | ||
124 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e) | ||
125 | { | ||
126 | free_experiment (e); | ||
127 | } | ||
128 | |||
129 | /* end of file ats-testing-experiment.c*/ | ||
130 | |||
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c index ab85e5f3d..9163d2cd1 100644 --- a/src/ats-tests/ats-testing-traffic.c +++ b/src/ats-tests/ats-testing-traffic.c | |||
@@ -50,7 +50,7 @@ send_ping_ready_cb (void *cls, size_t size, void *buf) | |||
50 | return 0; | 50 | return 0; |
51 | } | 51 | } |
52 | 52 | ||
53 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Master [%u]: Sending PING to [%u]\n", | 53 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Master [%u]: Sending PING to [%u]\n", |
54 | p->me->no, p->dest->no); | 54 | p->me->no, p->dest->no); |
55 | 55 | ||
56 | if (top->test_core) | 56 | if (top->test_core) |
@@ -146,7 +146,7 @@ comm_send_pong_ready (void *cls, size_t size, void *buf) | |||
146 | void | 146 | void |
147 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p) | 147 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p) |
148 | { | 148 | { |
149 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 149 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
150 | "Slave [%u]: Received PING from [%u], sending PONG\n", p->me->no, | 150 | "Slave [%u]: Received PING from [%u], sending PONG\n", p->me->no, |
151 | p->dest->no); | 151 | p->dest->no); |
152 | 152 | ||
@@ -176,7 +176,7 @@ void | |||
176 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | 176 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) |
177 | { | 177 | { |
178 | struct GNUNET_TIME_Relative left; | 178 | struct GNUNET_TIME_Relative left; |
179 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 179 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
180 | "Master [%u]: Received PONG from [%u], next message\n", p->me->no, | 180 | "Master [%u]: Received PONG from [%u], next message\n", p->me->no, |
181 | p->dest->no); | 181 | p->dest->no); |
182 | 182 | ||
@@ -204,6 +204,12 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | |||
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | /** | ||
208 | * Generate between the source master and the partner and send traffic with a | ||
209 | * maximum rate. | ||
210 | * | ||
211 | */ | ||
212 | |||
207 | struct TrafficGenerator * | 213 | struct TrafficGenerator * |
208 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 214 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, |
209 | struct BenchmarkPartner *dest, | 215 | struct BenchmarkPartner *dest, |
@@ -233,7 +239,7 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | |||
233 | tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; | 239 | tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; |
234 | 240 | ||
235 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 241 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
236 | "Setting up traffic generator between master[%u] `%s' and slave [%u] `%s' sending with max %u Bips\n", | 242 | "Setting up traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", |
237 | dest->me->no, GNUNET_i2s (&dest->me->id), | 243 | dest->me->no, GNUNET_i2s (&dest->me->id), |
238 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | 244 | dest->dest->no, GNUNET_i2s (&dest->dest->id), |
239 | rate); | 245 | rate); |
@@ -299,5 +305,5 @@ GNUNET_ATS_TEST_generate_traffic_stop_all () | |||
299 | } | 305 | } |
300 | } | 306 | } |
301 | 307 | ||
302 | /* end of file perf_ats_logging.c */ | 308 | /* end of file ats-testing-traffic.c */ |
303 | 309 | ||
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index b3301f19d..d57ce2667 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h | |||
@@ -382,6 +382,21 @@ struct GNUNET_ATS_TEST_Topology | |||
382 | void *done_cb_cls; | 382 | void *done_cb_cls; |
383 | }; | 383 | }; |
384 | 384 | ||
385 | struct Experiment | ||
386 | { | ||
387 | char *name; | ||
388 | char *cfg_file; | ||
389 | unsigned long long int num_masters; | ||
390 | unsigned long long int num_slaves; | ||
391 | struct GNUNET_TIME_Relative max_duration; | ||
392 | }; | ||
393 | |||
394 | struct Experiment * | ||
395 | GNUNET_ATS_TEST_experimentation_start (char *filename); | ||
396 | |||
397 | void | ||
398 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e); | ||
399 | |||
385 | 400 | ||
386 | struct TrafficGenerator * | 401 | struct TrafficGenerator * |
387 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 402 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, |
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c index 35320cf8f..8ba68c957 100644 --- a/src/ats-tests/gnunet-ats-sim.c +++ b/src/ats-tests/gnunet-ats-sim.c | |||
@@ -32,23 +32,13 @@ | |||
32 | #include "gnunet_core_service.h" | 32 | #include "gnunet_core_service.h" |
33 | #include "ats-testing.h" | 33 | #include "ats-testing.h" |
34 | 34 | ||
35 | #define DEFAULT_NUM_SLAVES 5 | ||
36 | #define DEFAULT_NUM_MASTERS 1 | ||
37 | |||
38 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 35 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
39 | 36 | ||
40 | static struct BenchmarkPeer *masters_p; | 37 | static struct BenchmarkPeer *masters_p; |
41 | static struct BenchmarkPeer *slaves_p; | 38 | static struct BenchmarkPeer *slaves_p; |
42 | 39 | ||
43 | /** | 40 | struct Experiment *e; |
44 | * Number of master peers to use | ||
45 | */ | ||
46 | static int c_masters; | ||
47 | 41 | ||
48 | /** | ||
49 | * Number of slave peers to use | ||
50 | */ | ||
51 | static int c_slaves; | ||
52 | 42 | ||
53 | static void | 43 | static void |
54 | evaluate () | 44 | evaluate () |
@@ -66,7 +56,7 @@ evaluate () | |||
66 | unsigned int rtt; | 56 | unsigned int rtt; |
67 | 57 | ||
68 | duration = (TEST_TIMEOUT.rel_value_us / (1000 * 1000)); | 58 | duration = (TEST_TIMEOUT.rel_value_us / (1000 * 1000)); |
69 | for (c_m = 0; c_m < c_masters; c_m++) | 59 | for (c_m = 0; c_m < e->num_masters; c_m++) |
70 | { | 60 | { |
71 | mp = &masters_p[c_m]; | 61 | mp = &masters_p[c_m]; |
72 | fprintf (stderr, | 62 | fprintf (stderr, |
@@ -76,7 +66,7 @@ evaluate () | |||
76 | mp->total_bytes_received / 1024, duration, | 66 | mp->total_bytes_received / 1024, duration, |
77 | (mp->total_bytes_received / 1024) / duration); | 67 | (mp->total_bytes_received / 1024) / duration); |
78 | 68 | ||
79 | for (c_s = 0; c_s < c_slaves; c_s++) | 69 | for (c_s = 0; c_s < e->num_slaves; c_s++) |
80 | { | 70 | { |
81 | p = &mp->partners[c_s]; | 71 | p = &mp->partners[c_s]; |
82 | 72 | ||
@@ -148,11 +138,12 @@ static void topology_setup_done (void *cls, | |||
148 | masters_p = masters; | 138 | masters_p = masters; |
149 | slaves_p = slaves; | 139 | slaves_p = slaves; |
150 | 140 | ||
151 | for (c_m = 0; c_m < c_masters; c_m++) | 141 | for (c_m = 0; c_m < e->num_masters; c_m++) |
152 | { | 142 | { |
153 | for (c_s = 0; c_s < c_slaves; c_s++) | 143 | for (c_s = 0; c_s < e->num_slaves; c_s++) |
154 | { | 144 | { |
155 | /* Generate maximum traffic to all peers */ | 145 | /* Generate maximum traffic to all peers */ |
146 | fprintf (stderr, "c_m %u c_s %u\n", c_m, c_s); | ||
156 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 147 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], |
157 | &masters[c_m].partners[c_s], | 148 | &masters[c_m].partners[c_s], |
158 | 10000, | 149 | 10000, |
@@ -166,13 +157,26 @@ static void topology_setup_done (void *cls, | |||
166 | int | 157 | int |
167 | main (int argc, char *argv[]) | 158 | main (int argc, char *argv[]) |
168 | { | 159 | { |
169 | c_slaves = DEFAULT_NUM_SLAVES; | 160 | if (argc < 2) |
170 | c_masters = DEFAULT_NUM_MASTERS; | 161 | { |
162 | fprintf (stderr, "No experiment given...\n"); | ||
163 | return 1; | ||
164 | } | ||
165 | |||
166 | fprintf (stderr, "Loading experiment `%s' \n", argv[1]); | ||
167 | e = GNUNET_ATS_TEST_experimentation_start (argv[1]); | ||
168 | if (NULL == e) | ||
169 | { | ||
170 | fprintf (stderr, "Invalid experiment\n"); | ||
171 | return 1; | ||
172 | } | ||
173 | |||
174 | fprintf (stderr, "%llu %llu\n", e->num_masters, e->num_slaves); | ||
171 | 175 | ||
172 | /* Setup a topology with */ | 176 | /* Setup a topology with */ |
173 | GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", "gnunet_ats_sim_default.conf", | 177 | GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", e->cfg_file, |
174 | c_slaves, | 178 | e->num_slaves, |
175 | c_masters, | 179 | e->num_masters, |
176 | GNUNET_NO, | 180 | GNUNET_NO, |
177 | &topology_setup_done, | 181 | &topology_setup_done, |
178 | NULL, | 182 | NULL, |