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 | |
parent | bacc609621a2a95bf5b3bea01c7673bb30a1e981 (diff) | |
download | gnunet-73a411bdf419bef89c47e1b8faaaa0a78c159ab1.tar.gz gnunet-73a411bdf419bef89c47e1b8faaaa0a78c159ab1.zip |
- testcase for 2d torus and fixes
-rw-r--r-- | src/testbed/Makefile.am | 13 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_testbed_run_topology2dtorus.conf | 80 | ||||
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 35 | ||||
-rw-r--r-- | src/testbed/testbed_api_topology.c | 3 |
4 files changed, 129 insertions, 2 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index a48fd138f..a08f320b8 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -95,7 +95,8 @@ check_PROGRAMS = \ | |||
95 | test_testbed_api_testbed_run_topologyline \ | 95 | test_testbed_api_testbed_run_topologyline \ |
96 | test_testbed_api_testbed_run_topologyclique \ | 96 | test_testbed_api_testbed_run_topologyclique \ |
97 | test_testbed_api_testbed_run_topologyring \ | 97 | test_testbed_api_testbed_run_topologyring \ |
98 | test_testbed_api_testbed_run_topologysmallworldring | 98 | test_testbed_api_testbed_run_topologysmallworldring \ |
99 | test_testbed_api_testbed_run_topology2dtorus | ||
99 | 100 | ||
100 | if ENABLE_TEST_RUN | 101 | if ENABLE_TEST_RUN |
101 | TESTS = \ | 102 | TESTS = \ |
@@ -114,7 +115,8 @@ if ENABLE_TEST_RUN | |||
114 | test_testbed_api_testbed_run_topologyline \ | 115 | test_testbed_api_testbed_run_topologyline \ |
115 | test_testbed_api_testbed_run_topologyclique \ | 116 | test_testbed_api_testbed_run_topologyclique \ |
116 | test_testbed_api_testbed_run_topologyring \ | 117 | test_testbed_api_testbed_run_topologyring \ |
117 | test_testbed_api_testbed_run_topologysmallworldring | 118 | test_testbed_api_testbed_run_topologysmallworldring \ |
119 | test_testbed_api_testbed_run_topology2dtorus | ||
118 | endif | 120 | endif |
119 | 121 | ||
120 | test_testbed_api_hosts_SOURCES = \ | 122 | test_testbed_api_hosts_SOURCES = \ |
@@ -218,6 +220,12 @@ test_testbed_api_testbed_run_topologysmallworldring_LDADD = \ | |||
218 | $(top_builddir)/src/util/libgnunetutil.la \ | 220 | $(top_builddir)/src/util/libgnunetutil.la \ |
219 | libgnunettestbed.la | 221 | libgnunettestbed.la |
220 | 222 | ||
223 | test_testbed_api_testbed_run_topology2dtorus_SOURCES = \ | ||
224 | test_testbed_api_testbed_run.c | ||
225 | test_testbed_api_testbed_run_topology2dtorus_LDADD = \ | ||
226 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
227 | libgnunettestbed.la | ||
228 | |||
221 | EXTRA_DIST = \ | 229 | EXTRA_DIST = \ |
222 | test_testbed_api.conf \ | 230 | test_testbed_api.conf \ |
223 | test_testbed_api_testbed_run_topologyring.conf \ | 231 | test_testbed_api_testbed_run_topologyring.conf \ |
@@ -225,4 +233,5 @@ EXTRA_DIST = \ | |||
225 | test_testbed_api_testbed_run_topologyline.conf \ | 233 | test_testbed_api_testbed_run_topologyline.conf \ |
226 | test_testbed_api_testbed_run_topologyrandom.conf \ | 234 | test_testbed_api_testbed_run_topologyrandom.conf \ |
227 | test_testbed_api_testbed_run_topologysmallworldring.conf \ | 235 | test_testbed_api_testbed_run_topologysmallworldring.conf \ |
236 | test_testbed_api_testbed_run_topology2dtorus.conf \ | ||
228 | sample_hosts.txt \ No newline at end of file | 237 | sample_hosts.txt \ No newline at end of file |
diff --git a/src/testbed/test_testbed_api_testbed_run_topology2dtorus.conf b/src/testbed/test_testbed_api_testbed_run_topology2dtorus.conf new file mode 100644 index 000000000..f3f966cfb --- /dev/null +++ b/src/testbed/test_testbed_api_testbed_run_topology2dtorus.conf | |||
@@ -0,0 +1,80 @@ | |||
1 | [testbed] | ||
2 | AUTOSTART = NO | ||
3 | PORT = 12113 | ||
4 | ACCEPT_FROM = 127.0.0.1; | ||
5 | HOSTNAME = localhost | ||
6 | NEIGHBOUR_LIMIT = 100 | ||
7 | PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2 | ||
8 | OVERLAY_TOPOLOGY = 2D_TORUS | ||
9 | #PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args | ||
10 | |||
11 | [fs] | ||
12 | AUTOSTART = NO | ||
13 | |||
14 | [resolver] | ||
15 | AUTOSTART = NO | ||
16 | |||
17 | [mesh] | ||
18 | AUTOSTART = NO | ||
19 | |||
20 | [dht] | ||
21 | AUTOSTART = NO | ||
22 | |||
23 | [block] | ||
24 | plugins = dht test | ||
25 | |||
26 | [dhtcache] | ||
27 | QUOTA = 1 MB | ||
28 | DATABASE = sqlite | ||
29 | |||
30 | [transport] | ||
31 | PLUGINS = tcp | ||
32 | ACCEPT_FROM6 = ::1; | ||
33 | ACCEPT_FROM = 127.0.0.1; | ||
34 | NEIGHBOUR_LIMIT = 50 | ||
35 | PORT = 12365 | ||
36 | |||
37 | [ats] | ||
38 | WAN_QUOTA_OUT = 3932160 | ||
39 | WAN_QUOTA_IN = 3932160 | ||
40 | |||
41 | [core] | ||
42 | PORT = 12092 | ||
43 | AUTOSTART = YES | ||
44 | |||
45 | [arm] | ||
46 | DEFAULTSERVICES = core transport | ||
47 | PORT = 12366 | ||
48 | |||
49 | [transport-tcp] | ||
50 | TIMEOUT = 300 s | ||
51 | PORT = 12368 | ||
52 | |||
53 | [TESTING] | ||
54 | NUM_PEERS = 5 | ||
55 | WEAKRANDOM = YES | ||
56 | HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat | ||
57 | MAX_CONCURRENT_SSH = 10 | ||
58 | USE_PROGRESSBARS = YES | ||
59 | PEERGROUP_TIMEOUT = 2400 s | ||
60 | |||
61 | [gnunetd] | ||
62 | HOSTKEY = $SERVICEHOME/.hostkey | ||
63 | |||
64 | [PATHS] | ||
65 | SERVICEHOME = /tmp/test-testbed/ | ||
66 | |||
67 | [dns] | ||
68 | AUTOSTART = NO | ||
69 | |||
70 | [nse] | ||
71 | AUTOSTART = NO | ||
72 | |||
73 | [vpn] | ||
74 | AUTOSTART = NO | ||
75 | |||
76 | [nat] | ||
77 | RETURN_LOCAL_ADDRESSES = YES | ||
78 | |||
79 | [gns-helper-service-w32] | ||
80 | AUTOSTART = NO \ No newline at end of file | ||
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); |
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c index 964f7f6a2..effc428e8 100644 --- a/src/testbed/testbed_api_topology.c +++ b/src/testbed/testbed_api_topology.c | |||
@@ -267,11 +267,14 @@ gen_topo_2dtorus (struct TopologyContext *tc) | |||
267 | rows_len[rows - 1] = ++x; | 267 | rows_len[rows - 1] = ++x; |
268 | else | 268 | else |
269 | rows_len[y++]++; | 269 | rows_len[y++]++; |
270 | num_peers++; | ||
270 | } | 271 | } |
271 | tc->link_array_size += (x < 2) ? x : 2 * x; | 272 | tc->link_array_size += (x < 2) ? x : 2 * x; |
272 | tc->link_array_size += (y < 2) ? y : 2 * y; | 273 | tc->link_array_size += (y < 2) ? y : 2 * y; |
273 | tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * | 274 | tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * |
274 | tc->link_array_size); | 275 | tc->link_array_size); |
276 | if (0 == rows_len[rows - 1]) | ||
277 | rows--; | ||
275 | cnt = 0; | 278 | cnt = 0; |
276 | offset = 0; | 279 | offset = 0; |
277 | for (y = 0; y < rows; y++) | 280 | for (y = 0; y < rows; y++) |