e6c878b64151a2b78f8b222ab1302df80646d682
[oweals/gnunet.git] / src / ats-tests / perf_ats.c
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/perf_ats.c
22  * @brief ats benchmark: start peers and modify preferences, monitor change over time
23  * @author Christian Grothoff
24  * @author Matthias Wachs
25  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_testbed_service.h"
29 #include "gnunet_ats_service.h"
30 #include "gnunet_core_service.h"
31 #include "perf_ats.h"
32
33
34 #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
35 #define TEST_ATS_PREFRENCE_START 1.0
36 #define TEST_ATS_PREFRENCE_DELTA 1.0
37
38 #define TEST_MESSAGE_TYPE_PING 12345
39 #define TEST_MESSAGE_TYPE_PONG 12346
40 #define TEST_MESSAGE_SIZE 1000
41 #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
42
43 /**
44  * Connect peers with testbed
45  */
46 struct TestbedConnectOperation
47 {
48   /**
49    * The benchmarking master initiating this connection
50    */
51   struct BenchmarkPeer *master;
52
53   /**
54    * The benchmarking slave to connect to
55    */
56   struct BenchmarkPeer *slave;
57
58   /**
59    * Testbed operation to connect peers
60    */
61   struct GNUNET_TESTBED_Operation *connect_op;
62 };
63
64 /**
65  * Overall state of the performance benchmark
66  */
67 struct BenchmarkState
68 {
69   /* Are we connected to ATS service of all peers: GNUNET_YES/NO */
70   int connected_ATS_service;
71
72   /* Are we connected to CORE service of all peers: GNUNET_YES/NO */
73   int connected_COMM_service;
74
75   /* Are we connected to all peers: GNUNET_YES/NO */
76   int connected_PEERS;
77
78   /* Are we connected to all slave peers on CORE level: GNUNET_YES/NO */
79   int connected_CORE;
80
81   /* Are we connected to CORE service of all peers: GNUNET_YES/NO */
82   int benchmarking;
83 };
84
85 /**
86  * Shutdown task
87  */
88 static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
89
90 /**
91  * Progress task
92  */
93 static GNUNET_SCHEDULER_TaskIdentifier progress_task;
94
95 /**
96  * Test result
97  */
98 static int result;
99
100 /**
101  * Test result logging
102  */
103 static int logging;
104
105 /**Test core (GNUNET_YES) or transport (GNUNET_NO)
106  */
107 static int test_core;
108
109 /**
110  * Solver string
111  */
112 static char *solver;
113
114 /**
115  * Preference string
116  */
117 static char *testname;
118
119 /**
120  * Preference string
121  */
122 static char *pref_str;
123
124 /**
125  * ATS preference value
126  */
127 static int pref_val;
128
129 /**
130  * Number master peers
131  */
132 static int num_masters;
133
134 /**
135  * Array of master peers
136  */
137 static  struct BenchmarkPeer *mps;
138
139 /**
140  * Number slave peers
141  */
142 static int num_slaves;
143 /**
144  * Array of slave peers
145  */
146 static struct BenchmarkPeer *sps;
147
148 /**
149  * Benchmark duration
150  */
151 static struct GNUNET_TIME_Relative perf_duration;
152
153 /**
154  * Logging frequency
155  */
156 static struct GNUNET_TIME_Relative log_frequency;
157
158 /**
159  * Benchmark state
160  */
161 static struct BenchmarkState state;
162
163 static void
164 evaluate ()
165 {
166   int c_m;
167   int c_s;
168   unsigned int duration;
169   struct BenchmarkPeer *mp;
170
171   duration = (perf_duration.rel_value_us / (1000 * 1000));
172   for (c_m = 0; c_m < num_masters; c_m++)
173   {
174     mp = &mps[c_m];
175     fprintf (stderr,
176         _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"),
177         mp->no, mp->total_bytes_sent / 1024, duration,
178         (mp->total_bytes_sent / 1024) / duration,
179         mp->total_bytes_received / 1024, duration,
180         (mp->total_bytes_received / 1024) / duration);
181
182     for (c_s = 0; c_s < num_slaves; c_s++)
183     {
184       fprintf (stderr,
185           "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f \%), received %u KiB/s (%.2f \%)\n",
186           (mp->pref_partner == mp->partners[c_s].dest) ? '*' : ' ',
187           mp->no, mp->partners[c_s].dest->no,
188           (mp->partners[c_s].bytes_sent / 1024) / duration,
189           ((double) mp->partners[c_s].bytes_sent * 100) / mp->total_bytes_sent,
190           (mp->partners[c_s].bytes_received / 1024) / duration,
191           ((double) mp->partners[c_s].bytes_received * 100) / mp->total_bytes_received );
192     }
193   }
194 }
195
196 /**
197  * Shutdown nicely
198  *
199  * @param cls NULL
200  * @param tc the task context
201  */
202 static void
203 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
204 {
205   int c_m;
206   int c_s;
207   int c_op;
208
209   if (GNUNET_YES == logging)
210     perf_logging_stop();
211
212   shutdown_task = GNUNET_SCHEDULER_NO_TASK;
213   if (GNUNET_SCHEDULER_NO_TASK != progress_task)
214   {
215     fprintf (stderr, "0\n");
216     GNUNET_SCHEDULER_cancel (progress_task);
217   }
218   progress_task = GNUNET_SCHEDULER_NO_TASK;
219
220   evaluate ();
221   state.benchmarking = GNUNET_NO;
222   GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
223
224   for (c_m = 0; c_m < num_masters; c_m++)
225   {
226     if (NULL != mps[c_m].peer_id_op)
227     {
228       GNUNET_TESTBED_operation_done (mps[c_m].peer_id_op);
229       mps[c_m].peer_id_op = NULL;
230     }
231
232     if (GNUNET_SCHEDULER_NO_TASK != mps[c_m].ats_task)
233       GNUNET_SCHEDULER_cancel (mps[c_m].ats_task);
234     mps[c_m].ats_task = GNUNET_SCHEDULER_NO_TASK;
235
236     for (c_op = 0; c_op < num_slaves; c_op++)
237     {
238
239       if (NULL != mps[c_m].partners[c_op].cth)
240       {
241         GNUNET_CORE_notify_transmit_ready_cancel (mps[c_m].partners[c_op].cth);
242         mps[c_m].partners[c_op].cth = NULL;
243       }
244       if (NULL != mps[c_m].partners[c_op].tth)
245       {
246         GNUNET_TRANSPORT_notify_transmit_ready_cancel (mps[c_m].partners[c_op].tth);
247         mps[c_m].partners[c_op].tth = NULL;
248       }
249
250
251       if (NULL != mps[c_m].core_connect_ops[c_op].connect_op)
252       {
253         GNUNET_log(GNUNET_ERROR_TYPE_INFO,
254             _("Failed to connect peer 0 and %u\n"), c_op);
255         GNUNET_TESTBED_operation_done (
256             mps[c_m].core_connect_ops[c_op].connect_op);
257         mps[c_m].core_connect_ops[c_op].connect_op = NULL;
258         result = 1;
259       }
260     }
261
262     if (NULL != mps[c_m].ats_perf_op)
263     {
264       GNUNET_TESTBED_operation_done (mps[c_m].ats_perf_op);
265       mps[c_m].ats_perf_op = NULL;
266     }
267
268     if (NULL != mps[c_m].comm_op)
269     {
270       GNUNET_TESTBED_operation_done (mps[c_m].comm_op);
271       mps[c_m].comm_op = NULL;
272     }
273     GNUNET_free(mps[c_m].core_connect_ops);
274     GNUNET_free(mps[c_m].partners);
275     mps[c_m].partners = NULL;
276   }
277
278   for (c_s = 0; c_s < num_slaves; c_s++)
279   {
280     if (NULL != sps[c_s].peer_id_op)
281     {
282       GNUNET_TESTBED_operation_done (sps[c_s].peer_id_op);
283       sps[c_s].peer_id_op = NULL;
284     }
285
286     for (c_op = 0; c_op < num_slaves; c_op++)
287     {
288       if (NULL != sps[c_s].partners[c_op].cth)
289       {
290         GNUNET_CORE_notify_transmit_ready_cancel (sps[c_s].partners[c_op].cth);
291         sps[c_s].partners[c_op].cth = NULL;
292       }
293
294       if (NULL != sps[c_s].partners[c_op].tth)
295       {
296         GNUNET_TRANSPORT_notify_transmit_ready_cancel (sps[c_s].partners[c_op].tth);
297         sps[c_s].partners[c_op].tth = NULL;
298       }
299     }
300
301     if (NULL != sps[c_s].ats_perf_op)
302     {
303       GNUNET_TESTBED_operation_done (sps[c_s].ats_perf_op);
304       sps[c_s].ats_perf_op = NULL;
305     }
306     if (NULL != sps[c_s].comm_op)
307     {
308       GNUNET_TESTBED_operation_done (sps[c_s].comm_op);
309       sps[c_s].comm_op = NULL;
310     }
311
312     GNUNET_free(sps[c_s].partners);
313     sps[c_s].partners = NULL;
314   }
315
316   GNUNET_SCHEDULER_shutdown ();
317 }
318
319 static struct BenchmarkPeer *
320 find_peer (const struct GNUNET_PeerIdentity * peer)
321 {
322   int c_p;
323
324   for (c_p = 0; c_p < num_masters; c_p++)
325   {
326     if (0 == memcmp (&mps[c_p].id, peer, sizeof(struct GNUNET_PeerIdentity)))
327       return &mps[c_p];
328   }
329
330   for (c_p = 0; c_p < num_slaves; c_p++)
331   {
332     if (0 == memcmp (&sps[c_p].id, peer, sizeof(struct GNUNET_PeerIdentity)))
333       return &sps[c_p];
334   }
335   return NULL ;
336 }
337
338 /**
339  * Controller event callback
340  *
341  * @param cls NULL
342  * @param event the controller event
343  */
344 static void
345 controller_event_cb (void *cls,
346     const struct GNUNET_TESTBED_EventInformation *event)
347 {
348   //struct BenchmarkPeer *p = cls;
349   switch (event->type)
350   {
351   case GNUNET_TESTBED_ET_CONNECT:
352     break;
353   case GNUNET_TESTBED_ET_OPERATION_FINISHED:
354     break;
355   default:
356     GNUNET_break(0);
357     result = 2;
358     GNUNET_SCHEDULER_cancel (shutdown_task);
359     shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL );
360   }
361 }
362
363 static size_t
364 comm_send_ready (void *cls, size_t size, void *buf)
365 {
366   static char msgbuf[TEST_MESSAGE_SIZE];
367   struct BenchmarkPartner *p = cls;
368   struct GNUNET_MessageHeader *msg;
369
370   if (GNUNET_YES == test_core)
371     p->cth = NULL;
372   else
373     p->tth = NULL;
374
375   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Master [%u]: Sending PING to [%u]\n",
376       p->me->no, p->dest->no);
377
378   p->messages_sent++;
379   p->bytes_sent += TEST_MESSAGE_SIZE;
380   p->me->total_messages_sent++;
381   p->me->total_bytes_sent += TEST_MESSAGE_SIZE;
382
383   msg = (struct GNUNET_MessageHeader *) &msgbuf;
384   memset (&msgbuf, 'a', TEST_MESSAGE_SIZE);
385   msg->type = htons (TEST_MESSAGE_TYPE_PING);
386   msg->size = htons (TEST_MESSAGE_SIZE);
387   memcpy (buf, msg, TEST_MESSAGE_SIZE);
388   return TEST_MESSAGE_SIZE;
389 }
390
391 static void
392 print_progress ()
393 {
394   static int calls;
395   progress_task = GNUNET_SCHEDULER_NO_TASK;
396
397   fprintf (stderr, "%llu..",
398       (long long unsigned) perf_duration.rel_value_us / (1000 * 1000) - calls);
399   calls++;
400
401   progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
402       &print_progress, NULL );
403 }
404
405 static void
406 ats_pref_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
407 {
408   struct BenchmarkPeer *me = cls;
409
410   me->ats_task = GNUNET_SCHEDULER_NO_TASK;
411
412   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, " Master [%u] set preference for slave [%u] to %f\n",
413       me->no, me->pref_partner->no, me->pref_value);
414   GNUNET_ATS_performance_change_preference (me->ats_perf_handle,
415       &me->pref_partner->id,
416       pref_val, me->pref_value, GNUNET_ATS_PREFERENCE_END);
417   me->pref_value += TEST_ATS_PREFRENCE_DELTA;
418   me->ats_task = GNUNET_SCHEDULER_add_delayed (TEST_ATS_PREFRENCE_FREQUENCY,
419       &ats_pref_task, cls);
420 }
421
422 static void
423 do_benchmark ()
424 {
425   int c_m;
426   int c_s;
427
428   if ((state.connected_ATS_service == GNUNET_NO)
429       || (state.connected_COMM_service == GNUNET_NO)
430       || (state.connected_PEERS == GNUNET_NO)
431       || (state.connected_CORE == GNUNET_NO))
432     return;
433
434   state.benchmarking = GNUNET_YES;
435   GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking start\n"));
436
437   if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
438     GNUNET_SCHEDULER_cancel (shutdown_task);
439   shutdown_task = GNUNET_SCHEDULER_add_delayed (perf_duration,
440       &do_shutdown, NULL );
441
442   progress_task = GNUNET_SCHEDULER_add_now (&print_progress, NULL );
443
444   /* Start sending test messages */
445   for (c_m = 0; c_m < num_masters; c_m++)
446   {
447     for (c_s = 0; c_s < num_slaves; c_s++)
448     {
449       if (GNUNET_YES == test_core)
450         mps[c_m].partners[c_s].cth = GNUNET_CORE_notify_transmit_ready (
451           mps[c_m].ch, GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &sps[c_s].id,
452           TEST_MESSAGE_SIZE, &comm_send_ready, &mps[c_m].partners[c_s]);
453       else
454       {
455         mps[c_m].partners[c_s].tth = GNUNET_TRANSPORT_notify_transmit_ready (
456           mps[c_m].th, &sps[c_s].id, TEST_MESSAGE_SIZE, 0,GNUNET_TIME_UNIT_MINUTES,
457           &comm_send_ready, &mps[c_m].partners[c_s]);
458       }
459     }
460     if (pref_val != GNUNET_ATS_PREFERENCE_END)
461       mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &mps[c_m]);
462   }
463   if (GNUNET_YES == logging)
464     perf_logging_start (log_frequency, testname, mps, num_masters);
465
466 }
467
468 static void
469 connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
470     const char *emsg)
471 {
472   struct TestbedConnectOperation *cop = cls;
473   static int ops = 0;
474   int c;
475   if (NULL == emsg)
476   {
477     GNUNET_log(GNUNET_ERROR_TYPE_INFO,
478         _("Connected master [%u] with slave [%u]\n"), cop->master->no,
479         cop->slave->no);
480   }
481   else
482   {
483     GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
484         _("Failed to connect master peer [%u] with slave [%u]\n"),
485         cop->master->no, cop->slave->no);
486     GNUNET_break(0);
487     if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
488       GNUNET_SCHEDULER_cancel (shutdown_task);
489     shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
490   }
491   GNUNET_TESTBED_operation_done (op);
492   ops++;
493   for (c = 0; c < num_slaves; c++)
494   {
495     if (cop == &cop->master->core_connect_ops[c])
496       cop->master->core_connect_ops[c].connect_op = NULL;
497   }
498   if (ops == num_masters * num_slaves)
499   {
500     state.connected_PEERS = GNUNET_YES;
501     GNUNET_SCHEDULER_add_now (&do_benchmark, NULL );
502   }
503 }
504
505 static void
506 do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
507 {
508   int c_m;
509   int c_s;
510   struct BenchmarkPeer *p;
511
512   if ((state.connected_ATS_service == GNUNET_NO)
513       || (state.connected_COMM_service == GNUNET_NO))
514     return;
515
516   GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Connecting peers on CORE level\n"));
517
518   for (c_m = 0; c_m < num_masters; c_m++)
519   {
520     p = &mps[c_m];
521     p->core_connect_ops = GNUNET_malloc (num_slaves *
522         sizeof (struct TestbedConnectOperation));
523
524     for (c_s = 0; c_s < num_slaves; c_s++)
525     {
526       GNUNET_log(GNUNET_ERROR_TYPE_INFO,
527           _("Connecting master [%u] with slave [%u]\n"), p->no, sps[c_s].no);
528       p->core_connect_ops[c_s].master = p;
529       p->core_connect_ops[c_s].slave = &sps[c_s];
530       p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (
531           NULL, &connect_completion_callback, &p->core_connect_ops[c_s],
532           sps[c_s].peer, p->peer);
533       if (NULL == p->core_connect_ops[c_s].connect_op)
534       {
535         GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
536             _("Could not connect master [%u] and slave [%u]\n"), p->no,
537             sps[c_s].no);
538         GNUNET_break(0);
539         if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
540           GNUNET_SCHEDULER_cancel (shutdown_task);
541         shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
542         return;
543       }
544     }
545   }
546 }
547
548 /**
549  * Method called whenever a given peer connects.
550  *
551  * @param cls closure
552  * @param peer peer identity this notification is about
553  */
554 static void
555 comm_connect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
556 {
557   struct BenchmarkPeer *me = cls;
558   struct BenchmarkPeer *remote;
559   char *id;
560   int c;
561   int completed;
562
563   remote = find_peer (peer);
564   if (NULL == remote)
565   {
566     GNUNET_break(0);
567     return;
568   }
569
570   id = GNUNET_strdup (GNUNET_i2s (&me->id));
571   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s [%u] `%s' connected to %s [%u] %s\n",
572       (me->master == GNUNET_YES) ? "Master": "Slave", me->no, id,
573       (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no,
574       GNUNET_i2s (peer));
575
576   me->core_connections++;
577   if ((GNUNET_YES == me->master) && (GNUNET_NO == remote->master)
578       && (GNUNET_NO == state.connected_CORE))
579   {
580     me->core_slave_connections++;
581
582     if (me->core_slave_connections == num_slaves)
583     {
584       GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Master [%u] connected all slaves\n",
585           me->no);
586     }
587     completed = GNUNET_YES;
588     for (c = 0; c < num_masters; c++)
589     {
590       if (mps[c].core_slave_connections != num_slaves)
591         completed = GNUNET_NO;
592     }
593     if (GNUNET_YES == completed)
594     {
595       GNUNET_log(GNUNET_ERROR_TYPE_INFO,
596           "All master peers connected all slave peers\n", id,
597           GNUNET_i2s (peer));
598       state.connected_CORE = GNUNET_YES;
599       GNUNET_SCHEDULER_add_now (&do_benchmark, NULL );
600     }
601   }
602   GNUNET_free(id);
603 }
604
605 static void
606 comm_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
607 {
608   struct BenchmarkPeer *me = cls;
609   struct BenchmarkPeer *remote;
610   char *id;
611
612   remote = find_peer (peer);
613   if (NULL == remote)
614   {
615     GNUNET_break(0);
616     return;
617   }
618
619   id = GNUNET_strdup (GNUNET_i2s (&me->id));
620   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id,
621       GNUNET_i2s (peer));
622   GNUNET_assert(me->core_connections > 0);
623   me->core_connections--;
624
625   if ((GNUNET_YES == state.benchmarking)
626       && ((GNUNET_YES == me->master) || (GNUNET_YES == remote->master)))
627   {
628     GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
629         "%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer));
630   }
631   GNUNET_free(id);
632 }
633
634 static size_t
635 comm_send_pong_ready (void *cls, size_t size, void *buf)
636 {
637   static char msgbuf[TEST_MESSAGE_SIZE];
638   struct BenchmarkPartner *p = cls;
639   struct GNUNET_MessageHeader *msg;
640
641   if (GNUNET_YES == test_core)
642     p->cth = NULL;
643   else
644     p->tth = NULL;
645
646   p->messages_sent++;
647   p->bytes_sent += TEST_MESSAGE_SIZE;
648   p->me->total_messages_sent++;
649   p->me->total_bytes_sent += TEST_MESSAGE_SIZE;
650
651   msg = (struct GNUNET_MessageHeader *) &msgbuf;
652   memset (&msgbuf, 'a', TEST_MESSAGE_SIZE);
653   msg->type = htons (TEST_MESSAGE_TYPE_PONG);
654   msg->size = htons (TEST_MESSAGE_SIZE);
655   memcpy (buf, msg, TEST_MESSAGE_SIZE);
656
657   return TEST_MESSAGE_SIZE;
658 }
659
660 static int
661 comm_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
662     const struct GNUNET_MessageHeader *message)
663 {
664   int c_m;
665   struct BenchmarkPeer *me = cls;
666   struct BenchmarkPartner *p = NULL;
667   for (c_m = 0; c_m < num_masters; c_m++)
668   {
669     /* Find a partner with other as destination */
670     if (0 == memcmp (other, &me->partners[c_m].dest->id,
671             sizeof(struct GNUNET_PeerIdentity)))
672     {
673       p = &me->partners[c_m];
674       break;
675     }
676   }
677   if (NULL == p)
678   {
679     GNUNET_break(0);
680     return GNUNET_SYSERR;
681   }
682
683   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
684       "Slave [%u]: Received PING from [%u], sending PONG\n", me->no,
685       p->dest->no);
686
687   p->messages_received++;
688   p->bytes_received += TEST_MESSAGE_SIZE;
689   p->me->total_messages_received++;
690   p->me->total_bytes_received += TEST_MESSAGE_SIZE;
691
692   if (GNUNET_YES == test_core)
693   {
694     GNUNET_assert (NULL == p->cth);
695     p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0,
696         GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE,
697         &comm_send_pong_ready, p);
698   }
699   else
700   {
701     GNUNET_assert (NULL == p->tth);
702     p->tth = GNUNET_TRANSPORT_notify_transmit_ready (me->th, &p->dest->id,
703         TEST_MESSAGE_SIZE, 0, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready,
704         p);
705   }
706   return GNUNET_OK;
707 }
708
709 static int
710 comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other,
711     const struct GNUNET_MessageHeader *message)
712 {
713   int c_s;
714   struct BenchmarkPeer *me = cls;
715   struct BenchmarkPartner *p = NULL;
716
717   for (c_s = 0; c_s < num_slaves; c_s++)
718   {
719     if (0
720         == memcmp (other, &me->partners[c_s].dest->id,
721             sizeof(struct GNUNET_PeerIdentity)))
722     {
723       p = &me->partners[c_s];
724       break;
725     }
726   }
727   if (NULL == p)
728   {
729     GNUNET_break(0);
730     return GNUNET_SYSERR;
731   }
732
733   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
734       "Master [%u]: Received PONG from [%u], next message\n", me->no,
735       p->dest->no);
736
737   p->messages_received++;
738   p->bytes_received += TEST_MESSAGE_SIZE;
739   p->me->total_messages_received++;
740   p->me->total_bytes_received += TEST_MESSAGE_SIZE;
741
742   if (GNUNET_YES == test_core)
743   {
744     GNUNET_assert (NULL == p->cth);
745     p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0,
746         GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE,
747         &comm_send_ready, p);
748   }
749   else
750   {
751     GNUNET_assert (NULL == p->tth);
752     p->tth = GNUNET_TRANSPORT_notify_transmit_ready (
753       me->th, &p->dest->id, TEST_MESSAGE_SIZE, 0,GNUNET_TIME_UNIT_MINUTES,
754       &comm_send_ready, p);
755   }
756
757   return GNUNET_OK;
758 }
759
760 static void *
761 core_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
762 {
763   struct BenchmarkPeer *me = cls;
764
765   static const struct GNUNET_CORE_MessageHandler handlers[] = { {
766       &comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, { &comm_handle_pong,
767       TEST_MESSAGE_TYPE_PONG, 0 }, { NULL, 0, 0 } };
768
769   me->ch = GNUNET_CORE_connect (cfg, me, NULL, comm_connect_cb,
770       comm_disconnect_cb, NULL, GNUNET_NO, NULL, GNUNET_NO, handlers);
771   if (NULL == me->ch)
772     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create core connection \n");
773   return me->ch;
774 }
775
776 static void
777 core_disconnect_adapter (void *cls, void *op_result)
778 {
779   struct BenchmarkPeer *me = cls;
780
781   GNUNET_CORE_disconnect (me->ch);
782   me->ch = NULL;
783 }
784
785 static void
786 comm_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
787     void *ca_result, const char *emsg)
788 {
789   static int comm_done = 0;
790   if ((NULL != emsg) || (NULL == ca_result))
791   {
792     GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
793     GNUNET_break(0);
794     if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
795       GNUNET_SCHEDULER_cancel (shutdown_task);
796     shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
797     return;
798   }
799   comm_done++;
800
801   if (comm_done == num_slaves + num_masters)
802   {
803     GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n",
804         (GNUNET_YES == test_core) ? "CORE" : "TRANSPORT");
805     state.connected_COMM_service = GNUNET_YES;
806     GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL );
807   }
808 }
809
810 static void
811 transport_recv_cb (void *cls,
812                    const struct GNUNET_PeerIdentity * peer,
813                    const struct GNUNET_MessageHeader * message)
814 {
815   if (TEST_MESSAGE_SIZE != ntohs (message->size) ||
816       (TEST_MESSAGE_TYPE_PING != ntohs (message->type) &&
817       TEST_MESSAGE_TYPE_PONG != ntohs (message->type)))
818   {
819     return;
820   }
821   if (TEST_MESSAGE_TYPE_PING == ntohs (message->type))
822     comm_handle_ping (cls, peer, message);
823
824   if (TEST_MESSAGE_TYPE_PONG == ntohs (message->type))
825     comm_handle_pong (cls, peer, message);
826 }
827
828
829 static void *
830 transport_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
831 {
832   struct BenchmarkPeer *me = cls;
833
834   me->th = GNUNET_TRANSPORT_connect (cfg, &me->id, me,  &transport_recv_cb,
835       &comm_connect_cb, &comm_disconnect_cb);
836   if (NULL == me->th)
837     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create transport connection \n");
838   return me->th;
839 }
840
841 static void
842 transport_disconnect_adapter (void *cls, void *op_result)
843 {
844   struct BenchmarkPeer *me = cls;
845
846   GNUNET_TRANSPORT_disconnect (me->th);
847   me->th = NULL;
848 }
849
850 static void
851 do_comm_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
852 {
853   int c_s;
854   int c_m;
855   GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all %s services\n",
856       (GNUNET_YES == test_core) ? "CORE" : "TRANSPORT");
857   for (c_m = 0; c_m < num_masters; c_m++)
858   {
859     if (GNUNET_YES == test_core)
860       mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, mps[c_m].peer,
861         "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
862         &core_disconnect_adapter, &mps[c_m]);
863     else
864     {
865       mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, mps[c_m].peer,
866         "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
867         &transport_disconnect_adapter, &mps[c_m]);
868     }
869   }
870
871   for (c_s = 0; c_s < num_slaves; c_s++)
872   {
873     if (GNUNET_YES == test_core)
874       sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, sps[c_s].peer,
875         "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
876         &core_disconnect_adapter, &sps[c_s]);
877     else
878     {
879       sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, sps[c_s].peer,
880         "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
881         &transport_disconnect_adapter, &sps[c_s]);
882     }
883   }
884 }
885
886 static void
887 ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
888     int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
889     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
890     const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
891 {
892   struct BenchmarkPeer *me = cls;
893   int c_a;
894   char *peer_id;
895
896   peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
897   for (c_a = 0; c_a < ats_count; c_a++)
898   {
899     /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("%c %03u: %s %s %u\n"),
900      (GNUNET_YES == p->master) ? 'M' : 'S',
901      p->no,
902      GNUNET_i2s (&address->peer),
903      GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)),
904      ntohl(ats[c_a].value));*/
905   }
906 #if 0
907   if ((GNUNET_YES == me->master)
908       && (0 == memcmp (&address->peer, &me->destination->id,
909               sizeof(struct GNUNET_PeerIdentity))))
910   {
911     GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Bandwidth for master %u: %lu %lu\n",
912         me->no, (long unsigned int ) ntohl (bandwidth_in.value__),
913         (long unsigned int ) ntohl (bandwidth_in.value__));
914   }
915
916   store_information (&bp->id, address, address_active, bandwidth_in,
917       bandwidth_out, ats, ats_count);
918 #endif
919   GNUNET_free(peer_id);
920 }
921
922 static void *
923 ats_perf_connect_adapter (void *cls,
924     const struct GNUNET_CONFIGURATION_Handle *cfg)
925 {
926   struct BenchmarkPeer *me = cls;
927
928   me->ats_perf_handle = GNUNET_ATS_performance_init (cfg,
929       &ats_performance_info_cb, me);
930   if (NULL == me->ats_perf_handle)
931     GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
932         "Failed to create ATS performance handle \n");
933   return me->ats_perf_handle;
934 }
935
936 static void
937 ats_perf_disconnect_adapter (void *cls, void *op_result)
938 {
939   struct BenchmarkPeer *me = cls;
940
941   GNUNET_ATS_performance_done (me->ats_perf_handle);
942   me->ats_perf_handle = NULL;
943 }
944
945 static void
946 ats_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
947     void *ca_result, const char *emsg)
948 {
949   static int op_done = 0;
950
951   if ((NULL != emsg) || (NULL == ca_result))
952   {
953     GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
954     GNUNET_break(0);
955     if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
956       GNUNET_SCHEDULER_cancel (shutdown_task);
957     shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
958     return;
959   }
960   op_done++;
961   if (op_done == (num_masters + num_slaves))
962   {
963     GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all ATS services\n");
964     state.connected_ATS_service = GNUNET_YES;
965     GNUNET_SCHEDULER_add_now (&do_comm_connect, NULL );
966   }
967 }
968
969 static void
970 do_connect_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
971 {
972   int c_m;
973   int c_s;
974
975   GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all ATS services\n");
976   for (c_m = 0; c_m < num_masters; c_m++)
977   {
978     mps[c_m].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, mps[c_m].peer,
979         "ats", ats_connect_completion_cb, NULL, &ats_perf_connect_adapter,
980         &ats_perf_disconnect_adapter, &mps[c_m]);
981
982   }
983
984   for (c_s = 0; c_s < num_slaves; c_s++)
985   {
986     sps[c_s].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, sps[c_s].peer,
987         "ats", ats_connect_completion_cb, NULL, &ats_perf_connect_adapter,
988         &ats_perf_disconnect_adapter, &sps[c_s]);
989   }
990
991 }
992
993 static void
994 peerinformation_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
995     const struct GNUNET_TESTBED_PeerInformation*pinfo, const char *emsg)
996 {
997   struct BenchmarkPeer *p = cb_cls;
998   static int done = 0;
999
1000   GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
1001
1002   p->id = *pinfo->result.id;
1003   GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n",
1004       (p->master == GNUNET_YES) ? "Master" : "Slave", p->no,
1005       GNUNET_i2s (&p->id));
1006
1007   GNUNET_TESTBED_operation_done (op);
1008   p->peer_id_op = NULL;
1009   done++;
1010
1011   if (done == num_slaves + num_masters)
1012   {
1013     GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1014         "Retrieved all peer ID, connect to ATS\n");
1015     GNUNET_SCHEDULER_add_now (&do_connect_ats, NULL );
1016   }
1017 }
1018
1019 /**
1020  * Signature of a main function for a testcase.
1021  *
1022  * @param cls closure
1023  * @param num_peers number of peers in 'peers'
1024  * @param peers_ handle to peers run in the testbed
1025  * @param links_succeeded the number of overlay link connection attempts that
1026  *          succeeded
1027  * @param links_failed the number of overlay link connection attempts that
1028  *          failed
1029  */
1030 static void
1031 main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers,
1032     struct GNUNET_TESTBED_Peer **peers_, unsigned int links_succeeded,
1033     unsigned int links_failed)
1034 {
1035   int c_m;
1036   int c_s;
1037   GNUNET_assert(NULL == cls);
1038   GNUNET_assert(num_masters + num_slaves == num_peers);
1039   GNUNET_assert(NULL != peers_);
1040
1041   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1042       _("Benchmarking solver `%s' on preference `%s' with %u master and %u slave peers\n"),
1043       solver, pref_str, num_masters, num_slaves);
1044
1045   shutdown_task = GNUNET_SCHEDULER_add_delayed (
1046       GNUNET_TIME_relative_multiply (TEST_TIMEOUT, num_masters + num_slaves),
1047       &do_shutdown, NULL );
1048
1049   /* Setup master peers */
1050   for (c_m = 0; c_m < num_masters; c_m++)
1051   {
1052     GNUNET_assert(NULL != peers_[c_m]);
1053     mps[c_m].peer = peers_[c_m];
1054     mps[c_m].no = c_m;
1055     mps[c_m].master = GNUNET_YES;
1056     mps[c_m].pref_partner = &sps[c_m];
1057     mps[c_m].pref_value = TEST_ATS_PREFRENCE_START;
1058     mps[c_m].partners =
1059         GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer));
1060     mps[c_m].num_partners = num_slaves;
1061     /* Initialize partners */
1062     for (c_s = 0; c_s < num_slaves; c_s++)
1063     {
1064       mps[c_m].partners[c_s].me = &mps[c_m];
1065       mps[c_m].partners[c_s].dest = &sps[c_s];
1066     }
1067     mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information (mps[c_m].peer,
1068         GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &mps[c_m]);
1069   }
1070
1071   /* Setup slave peers */
1072   for (c_s = 0; c_s < num_slaves; c_s++)
1073   {
1074     GNUNET_assert(NULL != peers_[c_s + num_masters]);
1075     sps[c_s].peer = peers_[c_s + num_masters];
1076     sps[c_s].no = c_s + num_masters;
1077     sps[c_s].master = GNUNET_NO;
1078     sps[c_s].partners =
1079         GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer));
1080     sps[c_s].num_partners = num_masters;
1081     /* Initialize partners */
1082     for (c_m = 0; c_m < num_masters; c_m++)
1083     {
1084       sps[c_s].partners[c_m].me = &sps[c_s];
1085       sps[c_s].partners[c_m].dest = &mps[c_m];
1086     }
1087     sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information (sps[c_s].peer,
1088         GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &sps[c_s]);
1089   }
1090 }
1091
1092 int
1093 main (int argc, char *argv[])
1094 {
1095   char *tmp;
1096   char *tmp_sep;
1097   char *test_name;
1098   char *conf_name;
1099   char *comm_name;
1100   char *dotexe;
1101   char *prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
1102   int c;
1103
1104   result = 0;
1105
1106   /* figure out testname */
1107   tmp = strstr (argv[0], TESTNAME_PREFIX);
1108   if (NULL == tmp)
1109   {
1110     fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]);
1111     return GNUNET_SYSERR;
1112   }
1113   tmp += strlen (TESTNAME_PREFIX);
1114   solver = GNUNET_strdup (tmp);
1115   if (NULL != (dotexe = strstr (solver, ".exe")) && dotexe[4] == '\0')
1116     dotexe[0] = '\0';
1117   tmp_sep = strchr (solver, '_');
1118   if (NULL == tmp_sep)
1119   {
1120     fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]);
1121     GNUNET_free(solver);
1122     return GNUNET_SYSERR;
1123   }
1124   tmp_sep[0] = '\0';
1125   comm_name = GNUNET_strdup (&tmp_sep[1]);
1126   tmp_sep = strchr (comm_name, '_');
1127   if (NULL == tmp_sep)
1128   {
1129     fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]);
1130     GNUNET_free(solver);
1131     return GNUNET_SYSERR;
1132   }
1133   tmp_sep[0] = '\0';
1134   for (c = 0; c <= strlen (comm_name); c++)
1135     comm_name[c] = toupper (comm_name[c]);
1136   if (0 == strcmp (comm_name, "CORE"))
1137     test_core = GNUNET_YES;
1138   else if (0 == strcmp (comm_name, "TRANSPORT"))
1139     test_core = GNUNET_NO;
1140   else
1141   {
1142     GNUNET_free (comm_name);
1143     GNUNET_free (solver);
1144     return GNUNET_SYSERR;
1145   }
1146
1147   pref_str = GNUNET_strdup(tmp_sep + 1);
1148
1149   GNUNET_asprintf (&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver,
1150       pref_str);
1151   GNUNET_asprintf (&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, pref_str);
1152
1153   for (c = 0; c <= strlen (pref_str); c++)
1154     pref_str[c] = toupper (pref_str[c]);
1155   pref_val = -1;
1156
1157   if (0 != strcmp (pref_str, "NONE"))
1158   {
1159     for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
1160     {
1161       if (0 == strcmp (pref_str, prefs[c]))
1162       {
1163         pref_val = c;
1164         break;
1165       }
1166     }
1167   }
1168   else
1169   {
1170     /* abuse terminator to indicate no pref */
1171     pref_val = GNUNET_ATS_PREFERENCE_END;
1172   }
1173   if (-1 == pref_val)
1174   {
1175     fprintf (stderr, "Unknown preference: `%s'\n", pref_str);
1176     GNUNET_free(solver);
1177     GNUNET_free(pref_str);
1178     GNUNET_free (comm_name);
1179     return -1;
1180   }
1181
1182   for (c = 0; c < (argc - 1); c++)
1183   {
1184     if (0 == strcmp (argv[c], "-d"))
1185       break;
1186   }
1187   if (c < argc - 1)
1188   {
1189     if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], &perf_duration))
1190         fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]);
1191   }
1192   else
1193   {
1194     perf_duration = BENCHMARK_DURATION;
1195   }
1196   fprintf (stderr, "Running benchmark for %llu secs\n", (unsigned long long) (perf_duration.rel_value_us) / (1000 * 1000));
1197
1198   for (c = 0; c < (argc - 1); c++)
1199   {
1200     if (0 == strcmp (argv[c], "-s"))
1201       break;
1202   }
1203   if (c < argc - 1)
1204   {
1205     if ((0L != (num_slaves = strtol (argv[c + 1], NULL, 10)))
1206         && (num_slaves >= 1))
1207       fprintf (stderr, "Starting %u slave peers\n", num_slaves);
1208     else
1209       num_slaves = DEFAULT_SLAVES_NUM;
1210   }
1211   else
1212     num_slaves = DEFAULT_SLAVES_NUM;
1213
1214   for (c = 0; c < (argc - 1); c++)
1215   {
1216     if (0 == strcmp (argv[c], "-m"))
1217       break;
1218   }
1219   if (c < argc - 1)
1220   {
1221     if ((0L != (num_masters = strtol (argv[c + 1], NULL, 10)))
1222         && (num_masters >= 2))
1223       fprintf (stderr, "Starting %u master peers\n", num_masters);
1224     else
1225       num_masters = DEFAULT_MASTERS_NUM;
1226   }
1227   else
1228     num_masters = DEFAULT_MASTERS_NUM;
1229
1230   logging = GNUNET_NO;
1231   for (c = 0; c < argc; c++)
1232   {
1233     if (0 == strcmp (argv[c], "-l"))
1234       logging = GNUNET_YES;
1235   }
1236
1237   if (GNUNET_YES == logging)
1238   {
1239     for (c = 0; c < (argc - 1); c++)
1240     {
1241       if (0 == strcmp (argv[c], "-f"))
1242         break;
1243     }
1244     if (c < argc - 1)
1245     {
1246       if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], &log_frequency))
1247           fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]);
1248     }
1249     else
1250     {
1251       log_frequency = LOGGING_FREQUENCY;
1252     }
1253     fprintf (stderr, "Using log frequency %llu ms\n",
1254         (unsigned long long) (log_frequency.rel_value_us) / (1000));
1255   }
1256
1257   GNUNET_asprintf (&testname, "%s_%s_%s",solver, comm_name, pref_str);
1258
1259   if (num_slaves < num_masters)
1260   {
1261     fprintf (stderr, "Number of master peers is lower than slaves! exit...\n");
1262     GNUNET_free(test_name);
1263     GNUNET_free(solver);
1264     GNUNET_free(pref_str);
1265     GNUNET_free (comm_name);
1266     return GNUNET_SYSERR;
1267   }
1268
1269   state.connected_ATS_service = GNUNET_NO;
1270   state.connected_COMM_service = GNUNET_NO;
1271   state.connected_PEERS = GNUNET_NO;
1272   state.benchmarking = GNUNET_NO;
1273   state.connected_PEERS = GNUNET_NO;
1274
1275   mps = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer));
1276   sps = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer));
1277
1278   /* Start topology */
1279   uint64_t event_mask;
1280   event_mask = 0;
1281   event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
1282   event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
1283   (void) GNUNET_TESTBED_test_run ("perf-ats", conf_name,
1284       num_slaves + num_masters, event_mask, &controller_event_cb, NULL,
1285       &main_run, NULL );
1286
1287   GNUNET_free(solver);
1288   GNUNET_free(pref_str);
1289   GNUNET_free(conf_name);
1290   GNUNET_free(test_name);
1291   GNUNET_free(testname);
1292   GNUNET_free (comm_name);
1293   GNUNET_free(mps);
1294   GNUNET_free(sps);
1295
1296   return result;
1297 }
1298
1299 /* end of file perf_ats.c */