diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-14 13:56:15 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-14 13:56:15 +0000 |
commit | 0ade08da2821a2069c0b0282b4ded2b9d2badfd8 (patch) | |
tree | f96dea175f7bc0107cdee0892f85f587acf94b73 /src/testbed | |
parent | e1bdd0f567da500d8ae723837b2c1e99bf992d4f (diff) | |
download | gnunet-0ade08da2821a2069c0b0282b4ded2b9d2badfd8.tar.gz gnunet-0ade08da2821a2069c0b0282b4ded2b9d2badfd8.zip |
peer linking
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-testbed-profiler.c | 74 | ||||
-rw-r--r-- | src/testbed/testbed_api_peers.c | 1 | ||||
-rw-r--r-- | src/testbed/testbed_api_topology.c | 8 |
3 files changed, 76 insertions, 7 deletions
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c index d51621117..675912e13 100644 --- a/src/testbed/gnunet-testbed-profiler.c +++ b/src/testbed/gnunet-testbed-profiler.c | |||
@@ -85,7 +85,12 @@ enum State | |||
85 | /** | 85 | /** |
86 | * Starting peers | 86 | * Starting peers |
87 | */ | 87 | */ |
88 | STATE_PEERS_STARTING | 88 | STATE_PEERS_STARTING, |
89 | |||
90 | /** | ||
91 | * Linking peers | ||
92 | */ | ||
93 | STATE_PEERS_LINKING | ||
89 | }; | 94 | }; |
90 | 95 | ||
91 | 96 | ||
@@ -135,6 +140,11 @@ struct DLLOperation *dll_op_head; | |||
135 | struct DLLOperation *dll_op_tail; | 140 | struct DLLOperation *dll_op_tail; |
136 | 141 | ||
137 | /** | 142 | /** |
143 | * Peer linking - topology operation | ||
144 | */ | ||
145 | struct GNUNET_TESTBED_Operation *topology_op; | ||
146 | |||
147 | /** | ||
138 | * Abort task identifier | 148 | * Abort task identifier |
139 | */ | 149 | */ |
140 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; | 150 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; |
@@ -175,6 +185,11 @@ static unsigned int num_peers; | |||
175 | static unsigned int num_hosts; | 185 | static unsigned int num_hosts; |
176 | 186 | ||
177 | /** | 187 | /** |
188 | * Number of random links to be established between peers | ||
189 | */ | ||
190 | static unsigned int num_links; | ||
191 | |||
192 | /** | ||
178 | * Global testing status | 193 | * Global testing status |
179 | */ | 194 | */ |
180 | static int result; | 195 | static int result; |
@@ -203,6 +218,8 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
203 | GNUNET_SCHEDULER_cancel (register_hosts_task); | 218 | GNUNET_SCHEDULER_cancel (register_hosts_task); |
204 | if (NULL != reg_handle) | 219 | if (NULL != reg_handle) |
205 | GNUNET_TESTBED_cancel_registration (reg_handle); | 220 | GNUNET_TESTBED_cancel_registration (reg_handle); |
221 | if (NULL != topology_op) | ||
222 | GNUNET_TESTBED_operation_cancel (topology_op); | ||
206 | for (nhost = 0; nhost < num_hosts; nhost++) | 223 | for (nhost = 0; nhost < num_hosts; nhost++) |
207 | if (NULL != hosts[nhost]) | 224 | if (NULL != hosts[nhost]) |
208 | GNUNET_TESTBED_host_destroy (hosts[nhost]); | 225 | GNUNET_TESTBED_host_destroy (hosts[nhost]); |
@@ -271,6 +288,19 @@ peer_churn_cb (void *cls, const char *emsg) | |||
271 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 288 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
272 | printf ("All peers started successfully in %.2f seconds\n", | 289 | printf ("All peers started successfully in %.2f seconds\n", |
273 | ((double) prof_time.rel_value) / 1000.00); | 290 | ((double) prof_time.rel_value) / 1000.00); |
291 | result = GNUNET_OK; | ||
292 | if (0 == num_links) | ||
293 | { | ||
294 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
295 | return; | ||
296 | } | ||
297 | state = STATE_PEERS_LINKING; | ||
298 | /* Do overlay connect */ | ||
299 | prof_start_time = GNUNET_TIME_absolute_get (); | ||
300 | topology_op = | ||
301 | GNUNET_TESTBED_overlay_configure_topology (NULL, num_peers, peers, | ||
302 | GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, | ||
303 | num_links); | ||
274 | } | 304 | } |
275 | } | 305 | } |
276 | 306 | ||
@@ -320,7 +350,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
320 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) | 350 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) |
321 | { | 351 | { |
322 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); | 352 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); |
323 | dll_op->op = GNUNET_TESTBED_peer_start (NULL, peers[peer_cnt], | 353 | dll_op->op = GNUNET_TESTBED_peer_start (dll_op, peers[peer_cnt], |
324 | &peer_churn_cb, dll_op); | 354 | &peer_churn_cb, dll_op); |
325 | GNUNET_CONTAINER_DLL_insert_tail (dll_op_head, dll_op_tail, dll_op); | 355 | GNUNET_CONTAINER_DLL_insert_tail (dll_op_head, dll_op_tail, dll_op); |
326 | } | 356 | } |
@@ -404,6 +434,38 @@ controller_event_cb (void *cls, | |||
404 | GNUNET_assert (0); | 434 | GNUNET_assert (0); |
405 | } | 435 | } |
406 | break; | 436 | break; |
437 | case STATE_PEERS_LINKING: | ||
438 | switch (event->type) | ||
439 | { | ||
440 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | ||
441 | /* Control reaches here when a peer linking operation fails */ | ||
442 | if (NULL != event->details.operation_finished.emsg) | ||
443 | { | ||
444 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
445 | _("An operation has failed while starting slaves\n")); | ||
446 | GNUNET_SCHEDULER_cancel (abort_task); | ||
447 | abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); | ||
448 | } | ||
449 | break; | ||
450 | case GNUNET_TESTBED_ET_CONNECT: | ||
451 | { | ||
452 | static unsigned int established_links; | ||
453 | |||
454 | if (++established_links == num_links) | ||
455 | { | ||
456 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | ||
457 | printf ("%u links established in %.2f seconds\n", | ||
458 | num_links, ((double) prof_time.rel_value) / 1000.00); | ||
459 | GNUNET_TESTBED_operation_done (topology_op); | ||
460 | topology_op = NULL; | ||
461 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
462 | } | ||
463 | } | ||
464 | break; | ||
465 | default: | ||
466 | GNUNET_assert (0); | ||
467 | } | ||
468 | break; | ||
407 | default: | 469 | default: |
408 | GNUNET_assert (0); | 470 | GNUNET_assert (0); |
409 | } | 471 | } |
@@ -590,12 +652,12 @@ int | |||
590 | main (int argc, char *const *argv) | 652 | main (int argc, char *const *argv) |
591 | { | 653 | { |
592 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 654 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
593 | { 'n', "num-peers", "COUNT", | 655 | { 'p', "num-peers", "COUNT", |
594 | gettext_noop ("create COUNT number of peers"), | ||
595 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers }, | ||
596 | { 'n', "num-peers", "COUNT", | ||
597 | gettext_noop ("create COUNT number of peers"), | 656 | gettext_noop ("create COUNT number of peers"), |
598 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers }, | 657 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers }, |
658 | { 'n', "num-links", "COUNT", | ||
659 | gettext_noop ("create COUNT number of random links"), | ||
660 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_links }, | ||
599 | GNUNET_GETOPT_OPTION_END | 661 | GNUNET_GETOPT_OPTION_END |
600 | }; | 662 | }; |
601 | int ret; | 663 | int ret; |
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index c85687e58..4902fc0f8 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c | |||
@@ -716,6 +716,7 @@ GNUNET_TESTBED_overlay_connect (void *op_cls, | |||
716 | opc->c = p1->controller; | 716 | opc->c = p1->controller; |
717 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); | 717 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
718 | opc->type = OP_OVERLAY_CONNECT; | 718 | opc->type = OP_OVERLAY_CONNECT; |
719 | opc->op_cls = op_cls; | ||
719 | opc->op = | 720 | opc->op = |
720 | GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect, | 721 | GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect, |
721 | &oprelease_overlay_connect); | 722 | &oprelease_overlay_connect); |
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c index 05537e2e1..47438ea3d 100644 --- a/src/testbed/testbed_api_topology.c +++ b/src/testbed/testbed_api_topology.c | |||
@@ -71,6 +71,11 @@ struct TopologyContext | |||
71 | struct GNUNET_TESTBED_Operation **link_ops; | 71 | struct GNUNET_TESTBED_Operation **link_ops; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * The operation closure | ||
75 | */ | ||
76 | void *op_cls; | ||
77 | |||
78 | /** | ||
74 | * The size of the link array | 79 | * The size of the link array |
75 | */ | 80 | */ |
76 | unsigned int link_array_size; | 81 | unsigned int link_array_size; |
@@ -122,7 +127,7 @@ opstart_overlay_configure_topology (void *cls) | |||
122 | for (p = 0; p < tc->link_array_size; p++) | 127 | for (p = 0; p < tc->link_array_size; p++) |
123 | { | 128 | { |
124 | tc->link_ops[p] = | 129 | tc->link_ops[p] = |
125 | GNUNET_TESTBED_overlay_connect (NULL, &overlay_link_completed, | 130 | GNUNET_TESTBED_overlay_connect (tc->op_cls, &overlay_link_completed, |
126 | &tc->link_ops[p], | 131 | &tc->link_ops[p], |
127 | tc->peers[tc->link_array[p].A], | 132 | tc->peers[tc->link_array[p].A], |
128 | tc->peers[tc->link_array[p].B]); | 133 | tc->peers[tc->link_array[p].B]); |
@@ -232,6 +237,7 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, | |||
232 | c = peers[0]->controller; | 237 | c = peers[0]->controller; |
233 | tc = GNUNET_malloc (sizeof (struct TopologyContext)); | 238 | tc = GNUNET_malloc (sizeof (struct TopologyContext)); |
234 | tc->peers = peers; | 239 | tc->peers = peers; |
240 | tc->op_cls = tc->op_cls; | ||
235 | switch (topo) | 241 | switch (topo) |
236 | { | 242 | { |
237 | case GNUNET_TESTBED_TOPOLOGY_LINE: | 243 | case GNUNET_TESTBED_TOPOLOGY_LINE: |