aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_ats.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-03-31 16:27:25 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-03-31 16:27:25 +0000
commit406f6b790cbc558d2ba6905c64a4ff8b90171daa (patch)
tree1b85c228837b841cf5636daa6c33f9471f7502cb /src/transport/test_transport_ats.c
parentdfe8a19d9d0aebc8711992a99628732dbe674621 (diff)
downloadgnunet-406f6b790cbc558d2ba6905c64a4ff8b90171daa.tar.gz
gnunet-406f6b790cbc558d2ba6905c64a4ff8b90171daa.zip
latest changes
Diffstat (limited to 'src/transport/test_transport_ats.c')
-rw-r--r--src/transport/test_transport_ats.c95
1 files changed, 71 insertions, 24 deletions
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c
index 2880da8e5..97b824249 100644
--- a/src/transport/test_transport_ats.c
+++ b/src/transport/test_transport_ats.c
@@ -31,7 +31,7 @@
31#define MEASUREMENTS 5 31#define MEASUREMENTS 5
32 32
33#define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 33#define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
35 35
36 36
37static int ok; 37static int ok;
@@ -51,16 +51,20 @@ struct GNUNET_TESTING_Daemon * master_deamon;
51 51
52struct GNUNET_STATISTICS_Handle * stats; 52struct GNUNET_STATISTICS_Handle * stats;
53 53
54struct ATS_result 54struct TEST_result
55{ 55{
56 uint64_t timestamp; 56 uint64_t timestamp;
57 int mechs; 57 uint64_t duration;
58 int peers; 58 uint64_t mechs;
59 int solution; 59 uint64_t peers;
60 uint64_t solution;
60}; 61};
61 62
62//static int index; 63static int r_index;
63static struct ATS_result results[MEASUREMENTS]; 64//static int measurements;
65static int peers;
66static struct TEST_result results[MEASUREMENTS];
67
64 68
65/** 69/**
66 * Check whether peers successfully shut down. 70 * Check whether peers successfully shut down.
@@ -95,47 +99,81 @@ static void shutdown_peers()
95 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 99 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
96} 100}
97 101
102static void evaluate_measurements()
103{
104 int c;
105 char * output = NULL;
106 char * temp;
107 for (c=0; c<MEASUREMENTS;c++)
108 {
109 GNUNET_asprintf(&temp, "%s ,%i,%llu,%llu,%llu,%llu,", (output==NULL) ? "" : output, c, results[c].peers, results[c].mechs, results[c].duration, results[c].solution);
110 GNUNET_free_non_null (output);
111 output = temp;
112 }
113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"%s\n",output);
114 shutdown_peers();
115}
116
98int stats_cb (void *cls, 117int stats_cb (void *cls,
99 const char *subsystem, 118 const char *subsystem,
100 const char *name, 119 const char *name,
101 uint64_t value, 120 uint64_t value,
102 int is_persistent) 121 int is_persistent)
103{ 122{
104 if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == NUM_PEERS-1)) 123 if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1))
105 { 124 {
106 measurement_started = GNUNET_YES; 125 measurement_started = GNUNET_YES;
107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 126 r_index = 0;
108 "All %llu peers connected\n", value); 127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value);
109 } 128 }
110 if (measurement_started == GNUNET_YES) 129 if (measurement_started == GNUNET_YES)
111 { 130 {
131 // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value);
112 if (0 == strcmp (name,"ATS timestamp")) 132 if (0 == strcmp (name,"ATS timestamp"))
113 { 133 {
114 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 134 if (results[r_index].timestamp == 0)
115 "ATS timestamp: %s %llu \n",name, value); 135 results[r_index].timestamp = value;
136 if (results[r_index].timestamp != value)
137 {
138 r_index++;
139 if (r_index >= MEASUREMENTS)
140 {
141 evaluate_measurements();
142 return GNUNET_NO;
143 }
144 results[r_index].timestamp = value;
145 }
146
147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
148 "[%i] ATS solution: %s %llu \n", r_index, name, value);
116 } 149 }
150
117 if (0 == strcmp (name,"ATS solution")) 151 if (0 == strcmp (name,"ATS solution"))
118 { 152 {
119 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 153 results[r_index].solution = value;
120 "ATS solution: %s %llu \n",name, value); 154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
155 "[%i] ATS solution: %s %llu \n", r_index, name, value);
121 } 156 }
157
122 if (0 == strcmp (name,"ATS peers")) 158 if (0 == strcmp (name,"ATS peers"))
123 { 159 {
124 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 160 results[r_index].peers = value;
125 "ATS peers: %s %llu \n",name, value); 161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
162 "[%i] ATS peers: %s %llu \n", r_index, name, value);
126 } 163 }
164
127 if (0 == strcmp (name,"ATS mechanisms")) 165 if (0 == strcmp (name,"ATS mechanisms"))
128 { 166 {
129 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 167 results[r_index].mechs = value;
130 "ATS mechanisms: %s %llu \n",name, value); 168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS mechanisms: %s %llu \n", r_index, name, value);
131 } 169 }
170
132 if (0 == strcmp (name,"ATS duration")) 171 if (0 == strcmp (name,"ATS duration"))
133 { 172 {
134 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 173 results[r_index].duration = value;
135 "ATS duration: %s %llu \n",name, value); 174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS duration: %s %llu \n", r_index, name, value);
136 } 175 }
137 } 176 }
138
139 return GNUNET_OK; 177 return GNUNET_OK;
140} 178}
141 179
@@ -154,7 +192,7 @@ stats_get_task (void *cls,
154 GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); 192 GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL);
155 GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); 193 GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL);
156 194
157 stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), &stats_get_task, NULL); 195 stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL);
158} 196}
159 197
160void 198void
@@ -262,7 +300,7 @@ run (void *cls,
262#if VERBOSE 300#if VERBOSE
263 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", NUM_PEERS); 301 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", NUM_PEERS);
264#endif 302#endif
265 peers_left = NUM_PEERS; 303 peers_left = peers;
266 pg = GNUNET_TESTING_daemons_start (cfg, 304 pg = GNUNET_TESTING_daemons_start (cfg,
267 peers_left, /* Total number of peers */ 305 peers_left, /* Total number of peers */
268 peers_left, /* Number of outstanding connections */ 306 peers_left, /* Number of outstanding connections */
@@ -298,13 +336,22 @@ main (int argc, char *argv[])
298{ 336{
299 int ret; 337 int ret;
300 338
301 GNUNET_log_setup ("test-testing-group", 339 GNUNET_log_setup ("test-transport-ats",
302#if VERBOSE 340#if VERBOSE
303 "DEBUG", 341 "DEBUG",
304#else 342#else
305 "WARNING", 343 "WARNING",
306#endif 344#endif
307 NULL); 345 NULL);
346
347 peers = NUM_PEERS;
348 if (argc >= 2)
349 {
350 peers = atoi(argv[1]);
351 peers++;
352 if(peers <1)
353 peers = NUM_PEERS;
354 }
308 ret = check (); 355 ret = check ();
309 /** 356 /**
310 * Still need to remove the base testing directory here, 357 * Still need to remove the base testing directory here,