diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-11-16 17:11:23 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-11-16 17:11:23 +0000 |
commit | 73a411bdf419bef89c47e1b8faaaa0a78c159ab1 (patch) | |
tree | c2a0c93c8beb9b18e8f70cdb016f05359c677b49 /src/testbed/testbed_api_testbed.c | |
parent | bacc609621a2a95bf5b3bea01c7673bb30a1e981 (diff) | |
download | gnunet-73a411bdf419bef89c47e1b8faaaa0a78c159ab1.tar.gz gnunet-73a411bdf419bef89c47e1b8faaaa0a78c159ab1.zip |
- testcase for 2d torus and fixes
Diffstat (limited to 'src/testbed/testbed_api_testbed.c')
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 11dedcd1f..cfe6370ea 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -670,6 +670,41 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
670 | rc->topology = GNUNET_TESTBED_TOPOLOGY_RING; | 670 | rc->topology = GNUNET_TESTBED_TOPOLOGY_RING; |
671 | rc->num_oc = num_peers; | 671 | rc->num_oc = num_peers; |
672 | } | 672 | } |
673 | else if (0 == strcasecmp (topology, "2D_TORUS")) | ||
674 | { | ||
675 | double sq; | ||
676 | unsigned int sq_floor; | ||
677 | unsigned int rows; | ||
678 | unsigned int *rows_len; | ||
679 | unsigned int x; | ||
680 | unsigned int y; | ||
681 | unsigned int n; | ||
682 | |||
683 | rc->topology = GNUNET_TESTBED_TOPOLOGY_2D_TORUS; | ||
684 | sq = sqrt ((double) num_peers); | ||
685 | sq = floor (sq); | ||
686 | sq_floor = (unsigned int) sq; | ||
687 | rows = (sq_floor + 1); | ||
688 | rows_len = GNUNET_malloc (sizeof (unsigned int) * rows); | ||
689 | for (y = 0; y < rows - 1; y++) | ||
690 | rows_len[y] = sq_floor; | ||
691 | n = sq_floor * sq_floor; | ||
692 | GNUNET_assert (n <= num_peers); | ||
693 | rc->num_oc = 2 * n; | ||
694 | x = 0; | ||
695 | y = 0; | ||
696 | while (n < num_peers) | ||
697 | { | ||
698 | if (x < y) | ||
699 | rows_len[rows - 1] = ++x; | ||
700 | else | ||
701 | rows_len[y++]++; | ||
702 | n++; | ||
703 | } | ||
704 | rc->num_oc += (x < 2) ? x : 2 * x; | ||
705 | rc->num_oc += (y < 2) ? y : 2 * y; | ||
706 | GNUNET_free (rows_len); | ||
707 | } | ||
673 | else | 708 | else |
674 | LOG (GNUNET_ERROR_TYPE_WARNING, | 709 | LOG (GNUNET_ERROR_TYPE_WARNING, |
675 | "Unknown topology %s given in configuration\n", topology); | 710 | "Unknown topology %s given in configuration\n", topology); |