GNUnet  0.10.x
ats-testing.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010-2013, 2016, 2017 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
27 #include "ats-testing.h"
28 
29 
34 {
39 
44 
49 };
50 
52 
54 
55 
61 static void
62 do_shutdown (void *cls)
63 {
64  int c_m;
65  int c_s;
66  int c_op;
67  struct BenchmarkPeer *p;
68 
70 
72  "Benchmarking done\n");
73 
75 
76  for (c_m = 0; c_m < top->num_masters; c_m++)
77  {
78  p = &top->mps[c_m];
79  if (NULL != top->mps[c_m].peer_id_op)
80  {
82  p->peer_id_op = NULL;
83  }
84 
85  if (NULL != p->ats_task)
87  p->ats_task = NULL;
88 
89  for (c_op = 0; c_op < p->num_partners; c_op++)
90  {
91  if ( (NULL != p->core_connect_ops) &&
92  (NULL != p->core_connect_ops[c_op].connect_op) )
93  {
95  "Failed to connect peer 0 and %u\n",
96  c_op);
98  p->core_connect_ops[c_op].connect_op = NULL;
99  }
100  }
101 
102  if (NULL != p->ats_perf_op)
103  {
105  p->ats_perf_op = NULL;
106  }
107 
108  if (NULL != p->comm_op)
109  {
111  p->comm_op = NULL;
112  }
114  GNUNET_free(p->partners);
115  p->partners = NULL;
116  }
117 
118  for (c_s = 0; c_s < top->num_slaves; c_s++)
119  {
120  p = &top->sps[c_s];
121  if (NULL != p->peer_id_op)
122  {
124  p->peer_id_op = NULL;
125  }
126  if (NULL != p->ats_perf_op)
127  {
129  p->ats_perf_op = NULL;
130  }
131  if (NULL != p->comm_op)
132  {
134  p->comm_op = NULL;
135  }
136  GNUNET_free(p->partners);
137  p->partners = NULL;
138  }
140  GNUNET_free (top);
141  top = NULL;
142 }
143 
144 
145 static struct BenchmarkPartner *
147  const struct GNUNET_PeerIdentity *peer)
148 {
149  int c_m;
150 
151  for (c_m = 0; c_m < me->num_partners; c_m++)
152  {
153  /* Find a partner with other as destination */
154  if (0 == GNUNET_memcmp (peer,
155  &me->partners[c_m].dest->id))
156  {
157  return &me->partners[c_m];
158  }
159  }
160 
161  return NULL;
162 }
163 
164 
165 static struct BenchmarkPeer *
167 {
168  int c_p;
169 
170  for (c_p = 0; c_p < top->num_masters; c_p++)
171  {
172  if (0 == GNUNET_memcmp (&top->mps[c_p].id,
173  peer))
174  return &top->mps[c_p];
175  }
176 
177  for (c_p = 0; c_p < top->num_slaves; c_p++)
178  {
179  if (0 == GNUNET_memcmp (&top->sps[c_p].id,
180  peer))
181  return &top->sps[c_p];
182  }
183  return NULL ;
184 }
185 
186 
195 static void *
196 comm_connect_cb (void *cls,
197  const struct GNUNET_PeerIdentity *peer,
198  struct GNUNET_MQ_Handle *mq)
199 {
200  struct BenchmarkPeer *me = cls;
201  struct BenchmarkPeer *remote;
202  struct BenchmarkPartner *p;
203  char *id;
204  int c;
205  int completed;
206 
207  remote = find_peer (peer);
208  if (NULL == remote)
209  {
211  "Unknown peer connected: `%s'\n",
212  GNUNET_i2s (peer));
213  GNUNET_break (0);
214  return NULL;
215  }
216 
217  id = GNUNET_strdup (GNUNET_i2s (&me->id));
219  "%s [%u] `%s' connected to %s [%u] %s\n",
220  (me->master == GNUNET_YES) ? "Master": "Slave",
221  me->no,
222  id,
223  (remote->master == GNUNET_YES) ? "Master": "Slave",
224  remote->no,
225  GNUNET_i2s (peer));
226 
227  me->core_connections++;
228  if ((GNUNET_YES == me->master) &&
229  (GNUNET_NO == remote->master) &&
230  (GNUNET_NO == top->state.connected_CORE))
231  {
233 
234  if (me->core_slave_connections == top->num_slaves)
235  {
237  "Master [%u] connected all slaves\n",
238  me->no);
239  }
240  completed = GNUNET_YES;
241  for (c = 0; c < top->num_masters; c++)
242  {
243  if (top->mps[c].core_slave_connections != top->num_slaves)
244  completed = GNUNET_NO;
245  }
246  if (GNUNET_YES == completed)
247  {
249  "All master peers connected all slave peers\n");
251  /* Notify about setup done */
252  if (NULL != top->done_cb)
253  top->done_cb (top->done_cb_cls,
254  top->mps,
255  top->sps);
256  }
257  }
258  GNUNET_free (id);
259  p = find_partner (me,
260  peer);
261  if (NULL != p)
262  p->mq = mq;
263  return p;
264 }
265 
266 
272 static void
274  const struct GNUNET_PeerIdentity *peer,
275  void *internal_cls)
276 {
277  struct BenchmarkPeer *me = cls;
278  struct BenchmarkPartner *p = internal_cls;
279  char *id;
280 
281  if (NULL == p)
282  return;
283 
284  id = GNUNET_strdup (GNUNET_i2s (&me->id));
286  "%s disconnected from %s\n",
287  id,
288  GNUNET_i2s (peer));
290  me->core_connections--;
291 
292  if ( (GNUNET_YES == top->state.benchmarking) &&
293  ( (GNUNET_YES == me->master) ||
294  (GNUNET_YES == p->dest->master) ) )
295  {
297  "%s disconnected from %s while benchmarking\n",
298  id,
299  GNUNET_i2s (peer));
300  }
301  GNUNET_free(id);
302 }
303 
304 
305 static void
306 handle_pong (void *cls,
307  const struct TestMessage *message)
308 {
309  struct BenchmarkPartner *p = cls;
310 
312 }
313 
314 
315 static void
316 handle_ping (void *cls,
317  const struct TestMessage *message)
318 {
319  struct BenchmarkPartner *p = cls;
320 
322 }
323 
324 
325 static void *
327  const struct GNUNET_CONFIGURATION_Handle *cfg)
328 {
329  struct BenchmarkPeer *me = cls;
330  struct GNUNET_MQ_MessageHandler handlers[] = {
333  struct TestMessage,
334  me),
337  struct TestMessage,
338  me),
340  };
341 
343  &me->id,
344  handlers,
345  me,
348  NULL);
349  if (NULL == me->th)
351  "Failed to create transport connection \n");
352  return me->th;
353 }
354 
355 
356 static void
358  void *op_result)
359 {
360  struct BenchmarkPeer *me = cls;
361 
363  me->th = NULL;
364 }
365 
366 
367 static void *
369  const struct GNUNET_CONFIGURATION_Handle *cfg)
370 {
371  struct BenchmarkPeer *me = cls;
372  struct GNUNET_MQ_MessageHandler handlers[] = {
375  struct TestMessage,
376  me),
379  struct TestMessage,
380  me),
382  };
383 
384  me->ch = GNUNET_CORE_connect (cfg,
385  me,
386  NULL,
389  handlers);
390  if (NULL == me->ch)
392  "Failed to create core connection \n");
393  return me->ch;
394 }
395 
396 
397 static void
399  void *op_result)
400 {
401  struct BenchmarkPeer *me = cls;
402 
404  me->ch = NULL;
405 }
406 
407 
408 static void
411  const char *emsg)
412 {
413  struct TestbedConnectOperation *cop = cls;
414  static int ops = 0;
415  int c;
416  if (NULL == emsg)
417  {
419  _("Connected master [%u] with slave [%u]\n"),
420  cop->master->no,
421  cop->slave->no);
422  }
423  else
424  {
426  _("Failed to connect master peer [%u] with slave [%u]\n"),
427  cop->master->no, cop->slave->no);
428  GNUNET_break(0);
430  }
432  ops++;
433  for (c = 0; c < top->num_slaves; c++)
434  {
435  if (cop == &cop->master->core_connect_ops[c])
436  cop->master->core_connect_ops[c].connect_op = NULL;
437  }
438  if (ops == top->num_masters * top->num_slaves)
439  {
441  }
442 }
443 
444 
445 static void
446 do_connect_peers (void *cls)
447 {
448  int c_m;
449  int c_s;
450  struct BenchmarkPeer *p;
451 
452  if ((top->state.connected_ATS_service == GNUNET_NO) ||
454  return;
455 
457  "Connecting peers on CORE level\n");
458  for (c_m = 0; c_m < top->num_masters; c_m++)
459  {
460  p = &top->mps[c_m];
462  sizeof (struct TestbedConnectOperation));
463 
464  for (c_s = 0; c_s < top->num_slaves; c_s++)
465  {
467  "Connecting master [%u] with slave [%u]\n",
468  p->no,
469  top->sps[c_s].no);
470  p->core_connect_ops[c_s].master = p;
471  p->core_connect_ops[c_s].slave = &top->sps[c_s];
475  &p->core_connect_ops[c_s],
476  top->sps[c_s].peer,
477  p->peer);
478  if (NULL == p->core_connect_ops[c_s].connect_op)
479  {
481  "Could not connect master [%u] and slave [%u]\n",
482  p->no,
483  top->sps[c_s].no);
484  GNUNET_break(0);
486  return;
487  }
488  }
489  }
490 }
491 
492 
493 static void
496  void *ca_result,
497  const char *emsg)
498 {
499  static int comm_done = 0;
500 
501  if ((NULL != emsg) || (NULL == ca_result))
502  {
504  "Initialization failed, shutdown\n");
505  GNUNET_break(0);
507  return;
508  }
509  comm_done++;
510 
511  if (comm_done == top->num_slaves + top->num_masters)
512  {
514  "Connected to all %s services\n",
515  (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
518  NULL);
519  }
520 }
521 
522 
523 static void
524 do_comm_connect (void *cls)
525 {
526  int c_s;
527  int c_m;
529  "Connecting to all %s services\n",
530  (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
531  for (c_m = 0; c_m < top->num_masters; c_m++)
532  {
533  if (GNUNET_YES == top->test_core)
534  top->mps[c_m].comm_op
536  top->mps[c_m].peer,
537  "core",
539  NULL,
542  &top->mps[c_m]);
543  else
544  {
545  top->mps[c_m].comm_op
547  top->mps[c_m].peer,
548  "transport",
550  NULL,
553  &top->mps[c_m]);
554  }
555  }
556 
557  for (c_s = 0; c_s < top->num_slaves; c_s++)
558  {
559  if (GNUNET_YES == top->test_core)
560  top->sps[c_s].comm_op
562  top->sps[c_s].peer,
563  "core",
565  NULL,
568  &top->sps[c_s]);
569  else
570  {
571  top->sps[c_s].comm_op
573  top->sps[c_s].peer,
574  "transport",
576  NULL,
579  &top->sps[c_s]);
580  }
581  }
582 }
583 
584 
585 static void
587  const struct GNUNET_HELLO_Address *address,
588  int address_active,
589  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
590  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
591  const struct GNUNET_ATS_Properties *ats_prop)
592 {
593  struct BenchmarkPeer *me = cls;
594  struct BenchmarkPartner *p;
595  int log;
596  char *peer_id;
597 
598  if (NULL == address)
599  {
601  "Peer %u: ATS Service disconnected!\n",
602  me->no);
603  return;
604  }
605 
606  p = find_partner (me,
607  &address->peer);
608  if (NULL == p)
609  {
610  /* This is not one of my partners
611  * Will happen since the peers will connect to each other due to gossiping
612  */
613  return;
614  }
615  peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
616 
617  log = GNUNET_NO;
618  if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
619  (p->bandwidth_out != ntohl (bandwidth_out.value__)))
620  log = GNUNET_YES;
621  p->bandwidth_in = ntohl (bandwidth_in.value__);
622  p->bandwidth_out = ntohl (bandwidth_out.value__);
623 
625  "%s [%u] received ATS information: %s\n",
626  (GNUNET_YES == p->me->master) ? "Master" : "Slave",
627  p->me->no,
628  GNUNET_i2s (&p->dest->id));
629 
630  p->props.utilization_out = ats_prop->utilization_out;
631  p->props.utilization_in = ats_prop->utilization_in;
632  p->props.scope = ats_prop->scope;
633  p->props.delay = ats_prop->delay;
634  p->props.distance = ats_prop->distance;
635 
636  if (GNUNET_YES == log)
637  top->ats_perf_cb (cls, address,
638  address_active,
639  bandwidth_out,
640  bandwidth_in,
641  ats_prop);
642  GNUNET_free(peer_id);
643 }
644 
645 
646 static void *
648  const struct GNUNET_CONFIGURATION_Handle *cfg)
649 {
650  struct BenchmarkPeer *me = cls;
651 
652  me->ats_perf_handle
655  me);
656  if (NULL == me->ats_perf_handle)
658  "Failed to create ATS performance handle \n");
659  return me->ats_perf_handle;
660 }
661 
662 
663 static void
665  void *op_result)
666 {
667  struct BenchmarkPeer *me = cls;
668 
670  me->ats_perf_handle = NULL;
671 }
672 
673 
674 static void
677  void *ca_result,
678  const char *emsg)
679 {
680  static int op_done = 0;
681 
682  if ((NULL != emsg) || (NULL == ca_result))
683  {
685  "Initialization failed, shutdown\n");
686  GNUNET_break(0);
688  return;
689  }
690  op_done++;
691  if (op_done == (top->num_masters + top->num_slaves))
692  {
694  "Connected to all ATS services\n");
697  NULL);
698  }
699 }
700 
701 
702 static void
703 do_connect_ats (void *cls)
704 {
705  int c_m;
706  int c_s;
707 
709  "Connecting to all ATS services\n");
710  for (c_m = 0; c_m < top->num_masters; c_m++)
711  {
712  top->mps[c_m].ats_perf_op
714  top->mps[c_m].peer,
715  "ats",
717  NULL,
720  &top->mps[c_m]);
721  }
722 
723  for (c_s = 0; c_s < top->num_slaves; c_s++)
724  {
725  top->sps[c_s].ats_perf_op
727  top->sps[c_s].peer,
728  "ats",
730  NULL,
733  &top->sps[c_s]);
734  }
735 }
736 
737 
738 
739 static void
740 peerinformation_cb (void *cb_cls,
742  const struct GNUNET_TESTBED_PeerInformation *pinfo,
743  const char *emsg)
744 {
745  struct BenchmarkPeer *p = cb_cls;
746  static int done = 0;
747 
749 
750  p->id = *pinfo->result.id;
752  "%s [%u] has peer id `%s'\n",
753  (p->master == GNUNET_YES) ? "Master" : "Slave",
754  p->no,
755  GNUNET_i2s (&p->id));
756 
758  p->peer_id_op = NULL;
759  done++;
760 
761  if (done == top->num_slaves + top->num_masters)
762  {
764  "Retrieved all peer ID, connect to ATS\n");
766  NULL);
767  }
768 }
769 
770 
783 static void
784 main_run (void *cls,
785  struct GNUNET_TESTBED_RunHandle *h,
786  unsigned int num_peers,
787  struct GNUNET_TESTBED_Peer **peers_,
788  unsigned int links_succeeded,
789  unsigned int links_failed)
790 {
791  int c_m;
792  int c_s;
793 
794  GNUNET_assert (NULL == cls);
795  GNUNET_assert (top->num_masters + top->num_slaves == num_peers);
796  GNUNET_assert (NULL != peers_);
797 
799  top);
800 
802  "Setting up %u masters and %u slaves\n",
803  top->num_masters,
804  top->num_slaves);
805 
806  /* Setup master peers */
807  for (c_m = 0; c_m < top->num_masters; c_m++)
808  {
809  GNUNET_assert(NULL != peers_[c_m]);
810  top->mps[c_m].peer = peers_[c_m];
811  top->mps[c_m].no = c_m;
812  top->mps[c_m].master = GNUNET_YES;
813  top->mps[c_m].pref_partner = &top->sps[c_m];
815  top->mps[c_m].partners =
816  GNUNET_malloc (top->num_slaves * sizeof (struct BenchmarkPartner));
817  top->mps[c_m].num_partners = top->num_slaves;
818  /* Initialize partners */
819  for (c_s = 0; c_s < top->num_slaves; c_s++)
820  {
821  top->mps[c_m].partners[c_s].me = &top->mps[c_m];
822  top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
823  }
824  /* Get configuration */
825  top->mps[c_m].peer_id_op
829  &top->mps[c_m]);
830  }
831 
832  /* Setup slave peers */
833  for (c_s = 0; c_s < top->num_slaves; c_s++)
834  {
835  GNUNET_assert(NULL != peers_[c_s + top->num_masters]);
836  top->sps[c_s].peer = peers_[c_s + top->num_masters];
837  top->sps[c_s].no = c_s + top->num_masters;
838  top->sps[c_s].master = GNUNET_NO;
839  top->sps[c_s].partners =
841  struct BenchmarkPartner);
842  top->sps[c_s].num_partners = top->num_masters;
843  /* Initialize partners */
844  for (c_m = 0; c_m < top->num_masters; c_m++)
845  {
846  top->sps[c_s].partners[c_m].me = &top->sps[c_s];
847  top->sps[c_s].partners[c_m].dest = &top->mps[c_m];
848 
849  /* Initialize properties */
850  top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO;
851  top->sps[c_s].partners[c_m].props.distance = 0;
852  top->sps[c_s].partners[c_m].props.scope = GNUNET_NT_UNSPECIFIED;
853  top->sps[c_s].partners[c_m].props.utilization_in = 0;
854  top->sps[c_s].partners[c_m].props.utilization_out = 0;
855  }
856  /* Get configuration */
857  top->sps[c_s].peer_id_op
861  &top->sps[c_s]);
862  }
863 }
864 
865 
872 static void
874  const struct GNUNET_TESTBED_EventInformation *event)
875 {
876  switch (event->type)
877  {
879  break;
881  break;
882  default:
883  GNUNET_break(0);
885  }
886 }
887 
888 
889 struct BenchmarkPeer *
891 {
892  if (src > top->num_masters)
893  return NULL;
894  return &top->mps[src];
895 }
896 
897 
898 struct BenchmarkPartner *
900  int dest)
901 {
902  if (src > top->num_masters)
903  return NULL;
904  if (dest > top->num_slaves)
905  return NULL;
906  return &top->mps[src].partners[dest];
907 }
908 
909 
922 void
924  unsigned int num_slaves,
925  unsigned int num_masters,
926  int test_core,
928  void *done_cb_cls,
930 {
931  top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
932  top->num_masters = num_masters;
933  top->num_slaves = num_slaves;
934  top->done_cb = done_cb;
935  top->done_cb_cls = done_cb_cls;
936  top->test_core = test_core;
937  top->ats_perf_cb = log_request_cb;
938  top->mps = GNUNET_new_array (num_masters,
939  struct BenchmarkPeer);
940  top->sps = GNUNET_new_array (num_slaves,
941  struct BenchmarkPeer);
942 
943  /* Start topology */
944  uint64_t event_mask;
945  event_mask = 0;
946  event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
947  event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
948  (void) GNUNET_TESTBED_test_run (name,
949  cfg_file,
950  num_slaves + num_masters,
951  event_mask,
952  &controller_event_cb, NULL,
953  &main_run, NULL);
954 }
955 
956 
960 void
962 {
963  if (NULL == top)
964  return;
966 }
967 
968 
969 /* end of file ats-testing.c */
struct BenchmarkPeer * slave
The benchmarking slave to connect to.
Definition: ats-testing.c:43
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
static void connect_completion_callback(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Definition: ats-testing.c:409
static void peerinformation_cb(void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
Definition: ats-testing.c:740
static void done()
int test_core
Test core (GNUNET_YES) or transport (GNUNET_NO)
Definition: ats-testing.h:406
struct GNUNET_TESTBED_Operation * comm_op
Testbed operation to connect to core.
Definition: ats-testing.h:146
int connected_CORE
Are we connected to all slave peers on CORE level: GNUNET_YES/NO.
Definition: ats-testing.h:382
static void ping(void *cls)
Send a ping to destination.
struct GNUNET_TESTBED_Operation * peer_id_op
Testbed operation to get peer information.
Definition: ats-testing.h:136
struct BenchmarkPeer * master
The benchmarking master initiating this connection.
Definition: ats-testing.c:38
Connect peers with testbed.
Definition: ats-testing.c:33
static void handle_pong(void *cls, const struct TestMessage *message)
Definition: ats-testing.c:306
union GNUNET_TESTBED_PeerInformation::@64 result
The result of the get information operation; Choose according to the pit.
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
static struct BenchmarkPartner * find_partner(struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity *peer)
Definition: ats-testing.c:146
struct GNUNET_TESTBED_Operation * ats_perf_op
Testbed operation to connect to ATS performance service.
Definition: ats-testing.h:141
#define TEST_ATS_PREFERENCE_DEFAULT
Definition: ats-testing.h:33
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_overlay_connect(void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2)
Both peers must have been started before calling this function.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
int GNUNET_TESTBED_test_run(const char *testname, const char *cfg_filename, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
Convenience method for running a "simple" test on the local system with a single call from &#39;main&#39;...
enum GNUNET_TESTBED_PeerInformationType pit
Peer information type; captures which of the types in the &#39;op_result&#39; is actually in use...
#define TEST_MESSAGE_TYPE_PONG
Message type sent as response during traffic generation.
Definition: ats-testing.h:43
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void * comm_connect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
Definition: ats-testing.c:196
static int op_result(struct GNUNET_OP_Handle *h, uint64_t op_id, int64_t result_code, const void *data, uint16_t data_size, void **ctx, uint8_t cancel)
Remove an operation, and call its result callback (unless it was cancelled).
Definition: op.c:244
struct GNUNET_CORE_Handle * ch
Core handle.
Definition: ats-testing.h:162
void GNUNET_ATS_TEST_traffic_handle_pong(struct BenchmarkPartner *p)
struct BenchmarkPartner * partners
Array of partners with num_slaves entries (if master) or num_master entries (if slave) ...
Definition: ats-testing.h:191
struct GNUNET_ATS_TEST_Topology * top
Definition: ats-testing.c:53
static void ats_performance_info_cb(void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *ats_prop)
Definition: ats-testing.c:586
struct GNUNET_TRANSPORT_CoreHandle * th
Transport handle.
Definition: ats-testing.h:167
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_ATS_performance_done(struct GNUNET_ATS_PerformanceHandle *ph)
Client is done using the ATS performance subsystem, release resources.
#define TEST_MESSAGE_TYPE_PING
Message type sent for traffic generation.
Definition: ats-testing.h:38
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:81
static void do_connect_ats(void *cls)
Definition: ats-testing.c:703
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
enum GNUNET_TESTBED_EventType type
Type of the event.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
int core_connections
Number of core connections.
Definition: ats-testing.h:201
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static void comm_disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Definition: ats-testing.c:273
ATS performance characteristics for an address.
static void handle_ping(void *cls, const struct TestMessage *message)
Definition: ats-testing.c:316
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
Opaque handle to an abstract operation to be executed by the testing framework.
double pref_value
Masters only Progress task.
Definition: ats-testing.h:185
uint32_t value__
The actual value (bytes per second).
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct GNUNET_PeerIdentity * id
The identity of the peer.
static void do_shutdown(void *cls)
Shutdown nicely.
Definition: ats-testing.c:62
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
Connect to a service offered by the given peer.
int num_partners
Number of partners.
Definition: ats-testing.h:196
int no
Unique identifier.
Definition: ats-testing.h:121
int benchmarking
Are we connected to CORE service of all peers: GNUNET_YES/NO.
Definition: ats-testing.h:387
void GNUNET_ATS_TEST_traffic_handle_ping(struct BenchmarkPartner *p)
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void * cls
Closure for mv and cb.
static void main_run(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers_, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
Definition: ats-testing.c:784
uint32_t bandwidth_in
Bandwidth assigned inbound.
Definition: ats-testing.h:340
Information we track for a peer in the testbed.
Definition: ats-testing.h:111
struct BenchmarkState state
Benchmark state.
Definition: ats-testing.h:461
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
int master
Is this peer a measter: GNUNET_YES/GNUNET_NO.
Definition: ats-testing.h:126
A requested testbed operation has been completed.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
Information about a benchmarking partner.
Definition: ats-testing.h:275
struct GNUNET_TIME_Relative delay
Delay.
static void * core_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Definition: ats-testing.c:368
struct GNUNET_ATS_PerformanceHandle * ats_perf_handle
ATS performance handle.
Definition: ats-testing.h:151
uint32_t bandwidth_out
Bandwidth assigned outbound.
Definition: ats-testing.h:345
ats testing library: setup topology and provide logging to test ats
static const char * cfg_file
Configuration filename.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2046
int core_slave_connections
Masters only: Number of connections to slave peers.
Definition: ats-testing.h:207
Message handler for a specific message type.
static void * ats_perf_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Definition: ats-testing.c:647
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_get_information(struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_PeerInformationType pit, GNUNET_TESTBED_PeerInfoCallback cb, void *cb_cls)
Request information about a peer.
void GNUNET_ATS_TEST_shutdown_topology(void)
Shutdown topology.
Definition: ats-testing.c:961
void(* GNUNET_ATS_AddressInformationCallback)(void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop)
Signature of a function that is called with QoS information about an address.
static void pong(struct GNUNET_CADET_Channel *channel, const struct CadetPingMessage *ping)
Reply with a pong to origin.
uint64_t event_mask
Global event mask for all testbed events.
unsigned int num_slaves
Number slave peers.
Definition: ats-testing.h:441
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static void comm_connect_completion_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Definition: ats-testing.c:494
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
Definition: core_api.c:694
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:732
const char * name
int connected_PEERS
Are we connected to all peers: GNUNET_YES/NO.
Definition: ats-testing.h:377
struct BenchmarkPeer * sps
Array of slave peers.
Definition: ats-testing.h:446
struct BenchmarkPeer * mps
Array of master peers.
Definition: ats-testing.h:436
struct GNUNET_PeerIdentity peer
For which peer is this an address?
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
A connection between two peers was established.
static unsigned int num_peers
GNUNET_ATS_AddressInformationCallback ats_perf_cb
Definition: ats-testing.h:465
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
static void * transport_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Definition: ats-testing.c:326
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_ATS_PerformanceHandle * GNUNET_ATS_performance_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressInformationCallback addr_info_cb, void *addr_info_cb_cls)
Get handle to access performance API of the ATS subsystem.
Handle to a message queue.
Definition: mq.c:85
struct BenchmarkPartner * GNUNET_ATS_TEST_get_partner(int src, int dest)
Definition: ats-testing.c:899
struct GNUNET_SCHEDULER_Task * ats_task
Masters only Progress task.
Definition: ats-testing.h:179
The identity of the host (wraps the signing key of the peer).
struct GNUNET_MQ_Handle * mq
Message queue handle.
Definition: ats-testing.h:290
What is the identity of the peer? Returns a &#39;const struct GNUNET_PeerIdentity *&#39;. ...
static void ats_perf_disconnect_adapter(void *cls, void *op_result)
Definition: ats-testing.c:664
configuration data
Definition: configuration.c:85
static void do_connect_peers(void *cls)
Definition: ats-testing.c:446
struct BenchmarkPeer * GNUNET_ATS_TEST_get_peer(int src)
Topology related functions.
Definition: ats-testing.c:890
static void controller_event_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Controller event callback.
Definition: ats-testing.c:873
An address for communicating with a peer.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
int connected_ATS_service
Are we connected to ATS service of all peers: GNUNET_YES/NO.
Definition: ats-testing.h:367
struct BenchmarkPeer * pref_partner
Masters only: Peer to set ATS preferences for.
Definition: ats-testing.h:173
void GNUNET_ATS_TEST_generate_traffic_stop_all()
Stop all traffic generators.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_ATS_TEST_create_topology(char *name, char *cfg_file, unsigned int num_slaves, unsigned int num_masters, int test_core, GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, void *done_cb_cls, GNUNET_ATS_AddressInformationCallback log_request_cb)
Create a topology for ats testing.
Definition: ats-testing.c:923
struct GNUNET_ATS_Properties props
Current ATS properties.
Definition: ats-testing.h:335
static void do_comm_connect(void *cls)
Definition: ats-testing.c:524
struct TestbedConnectOperation * core_connect_ops
Masters only: Testbed connect operations to connect masters to slaves.
Definition: ats-testing.h:157
void(* GNUNET_ATS_TEST_TopologySetupDoneCallback)(void *cls, struct BenchmarkPeer *masters, struct BenchmarkPeer *slaves)
Callback to call when topology setup is completed.
Definition: ats-testing.h:85
int connected_COMM_service
Are we connected to CORE service of all peers: GNUNET_YES/NO.
Definition: ats-testing.h:372
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
struct BenchmarkPeer * me
The peer itself this partner belongs to.
Definition: ats-testing.h:280
A peer controlled by the testing framework.
unsigned int distance
Distance on network layer (required for distance-vector routing) in hops.
GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb
Definition: ats-testing.h:463
static void core_disconnect_adapter(void *cls, void *op_result)
Definition: ats-testing.c:398
static char * address
GNS address for this phone.
unsigned int num_masters
Number master peers.
Definition: ats-testing.h:431
struct GNUNET_TESTBED_Operation * connect_op
Testbed operation to connect peers.
Definition: ats-testing.c:48
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct BenchmarkPeer * dest
The partner peer.
Definition: ats-testing.h:285
struct GNUNET_TESTBED_Peer * peer
Handle with testbed.
Definition: ats-testing.h:116
struct GNUNET_PeerIdentity id
Peer ID.
Definition: ats-testing.h:131
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
Definition: ats-testing.c:51
#define GNUNET_free(ptr)
Wrapper around free.
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
Data returned from GNUNET_TESTBED_peer_get_information.
Category of last resort.
Definition: gnunet_nt_lib.h:40
static void transport_disconnect_adapter(void *cls, void *op_result)
Definition: ats-testing.c:357
static void ats_connect_completion_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Definition: ats-testing.c:675
static struct BenchmarkPeer * find_peer(const struct GNUNET_PeerIdentity *peer)
Definition: ats-testing.c:166
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965