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 /src/ats-tests/gnunet-ats-sim.c | |
parent | d3ce95bec0495962ad80d3eba9b5e11e09a2b25d (diff) | |
download | gnunet-74e92716b7dd1e117cb8ef932348335c98daa0e1.tar.gz gnunet-74e92716b7dd1e117cb8ef932348335c98daa0e1.zip |
experimentation basics
Diffstat (limited to 'src/ats-tests/gnunet-ats-sim.c')
-rw-r--r-- | src/ats-tests/gnunet-ats-sim.c | 44 |
1 files changed, 24 insertions, 20 deletions
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, |