diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-11-12 18:13:55 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-11-12 18:13:55 +0000 |
commit | cd07db057216ad47693bde4c38b45013628465b0 (patch) | |
tree | cd52fb1986c6b051bf5b67517de2700cf8478869 /src/testbed/testbed_api_testbed.c | |
parent | 61a51d59b76d8c0ab20e06314e7c2581a2b595a1 (diff) | |
download | gnunet-cd07db057216ad47693bde4c38b45013628465b0.tar.gz gnunet-cd07db057216ad47693bde4c38b45013628465b0.zip |
implementing small world ring topology
Diffstat (limited to 'src/testbed/testbed_api_testbed.c')
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 6da0b1075..d597d47a6 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -423,15 +423,19 @@ call_cc: | |||
423 | if (rc->peer_count < rc->num_peers) | 423 | if (rc->peer_count < rc->num_peers) |
424 | return; | 424 | return; |
425 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers started successfully\n"); | 425 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers started successfully\n"); |
426 | if (GNUNET_TESTBED_TOPOLOGY_OPTION_END != rc->topology) | 426 | if (GNUNET_TESTBED_TOPOLOGY_NONE != rc->topology) |
427 | { | 427 | { |
428 | if (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology) | 428 | if ( (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology) |
429 | || (GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING == rc->topology)) | ||
429 | rc->topology_operation = | 430 | rc->topology_operation = |
430 | GNUNET_TESTBED_overlay_configure_topology (NULL, | 431 | GNUNET_TESTBED_overlay_configure_topology (NULL, |
431 | rc->num_peers, | 432 | rc->num_peers, |
432 | rc->peers, | 433 | rc->peers, |
433 | rc->topology, | 434 | rc->topology, |
434 | rc->num_oc, | 435 | (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI |
436 | == rc->topology) ? | ||
437 | rc->num_oc : | ||
438 | (rc->num_oc - rc->num_peers), | ||
435 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); | 439 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); |
436 | else | 440 | else |
437 | rc->topology_operation = | 441 | rc->topology_operation = |
@@ -479,7 +483,7 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
479 | event_mask = rc->event_mask; | 483 | event_mask = rc->event_mask; |
480 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); | 484 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); |
481 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 485 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
482 | if (rc->topology < GNUNET_TESTBED_TOPOLOGY_OPTION_END) | 486 | if (rc->topology < GNUNET_TESTBED_TOPOLOGY_NONE) |
483 | event_mask |= GNUNET_TESTBED_ET_CONNECT; | 487 | event_mask |= GNUNET_TESTBED_ET_CONNECT; |
484 | rc->c = | 488 | rc->c = |
485 | GNUNET_TESTBED_controller_connect (cfg, rc->h, event_mask, &event_cb, rc); | 489 | GNUNET_TESTBED_controller_connect (cfg, rc->h, event_mask, &event_cb, rc); |
@@ -624,33 +628,18 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
624 | rc->master = master; | 628 | rc->master = master; |
625 | rc->master_cls = master_cls; | 629 | rc->master_cls = master_cls; |
626 | rc->state = RC_INIT; | 630 | rc->state = RC_INIT; |
627 | rc->topology = GNUNET_TESTBED_TOPOLOGY_OPTION_END; | 631 | rc->topology = GNUNET_TESTBED_TOPOLOGY_NONE; |
628 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "testbed", | 632 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "testbed", |
629 | "OVERLAY_TOPOLOGY", | 633 | "OVERLAY_TOPOLOGY", |
630 | &topology)) | 634 | &topology)) |
631 | { | 635 | { |
632 | if (0 == strcasecmp (topology, "RANDOM")) | 636 | if (0 == strcasecmp (topology, "RANDOM")) |
633 | { | 637 | { |
634 | rc->topology = GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI; | 638 | rc->topology = GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI; |
635 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testbed", | 639 | } |
636 | "OVERLAY_RANDOM_LINKS", | 640 | else if (0 == strcasecmp (topology, "SMALL_WORLD_RING")) |
637 | &random_links)) | 641 | { |
638 | { | 642 | rc->topology = GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING; |
639 | /* OVERLAY option RANDOM requires OVERLAY_RANDOM_LINKS option to */ | ||
640 | /* be set to the number of random links to be established */ | ||
641 | GNUNET_break (0); | ||
642 | GNUNET_free (rc); | ||
643 | GNUNET_free (topology); | ||
644 | return; | ||
645 | } | ||
646 | if (random_links > UINT32_MAX) | ||
647 | { | ||
648 | GNUNET_break (0); /* Too big number */ | ||
649 | GNUNET_free (rc); | ||
650 | GNUNET_free (topology); | ||
651 | return; | ||
652 | } | ||
653 | rc->num_oc = (unsigned int) random_links; | ||
654 | } | 643 | } |
655 | else if (0 == strcasecmp (topology, "CLIQUE")) | 644 | else if (0 == strcasecmp (topology, "CLIQUE")) |
656 | { | 645 | { |
@@ -672,6 +661,29 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
672 | "Unknown topology %s given in configuration\n", topology); | 661 | "Unknown topology %s given in configuration\n", topology); |
673 | GNUNET_free (topology); | 662 | GNUNET_free (topology); |
674 | } | 663 | } |
664 | if ( (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology) | ||
665 | || (GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING == rc->topology)) | ||
666 | { | ||
667 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testbed", | ||
668 | "OVERLAY_RANDOM_LINKS", | ||
669 | &random_links)) | ||
670 | { | ||
671 | /* OVERLAY option RANDOM & SMALL_WORLD_RING requires OVERLAY_RANDOM_LINKS | ||
672 | option to be set to the number of random links to be established */ | ||
673 | GNUNET_break (0); | ||
674 | GNUNET_free (rc); | ||
675 | return; | ||
676 | } | ||
677 | if (random_links > UINT32_MAX) | ||
678 | { | ||
679 | GNUNET_break (0); /* Too big number */ | ||
680 | GNUNET_free (rc); | ||
681 | return; | ||
682 | } | ||
683 | rc->num_oc = (unsigned int) random_links; | ||
684 | if (GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING == rc->topology) | ||
685 | rc->num_oc += num_peers; | ||
686 | } | ||
675 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 687 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
676 | &shutdown_run_task, rc); | 688 | &shutdown_run_task, rc); |
677 | } | 689 | } |
@@ -703,7 +715,7 @@ GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller, | |||
703 | enum GNUNET_TESTBED_TopologyOption underlay_topology, | 715 | enum GNUNET_TESTBED_TopologyOption underlay_topology, |
704 | va_list va) | 716 | va_list va) |
705 | { | 717 | { |
706 | GNUNET_assert (underlay_topology < GNUNET_TESTBED_TOPOLOGY_OPTION_END); | 718 | GNUNET_assert (underlay_topology < GNUNET_TESTBED_TOPOLOGY_NONE); |
707 | GNUNET_break (0); | 719 | GNUNET_break (0); |
708 | return NULL; | 720 | return NULL; |
709 | } | 721 | } |