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 | |
parent | 61a51d59b76d8c0ab20e06314e7c2581a2b595a1 (diff) | |
download | gnunet-cd07db057216ad47693bde4c38b45013628465b0.tar.gz gnunet-cd07db057216ad47693bde4c38b45013628465b0.zip |
implementing small world ring topology
-rw-r--r-- | src/testbed/Makefile.am | 13 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_testbed_run_topologyrandom.conf | 1 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_testbed_run_topologysmallworldring.conf | 80 | ||||
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 66 | ||||
-rw-r--r-- | src/testbed/testbed_api_topology.c | 146 |
5 files changed, 239 insertions, 67 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index 9eee7cf4e..a48fd138f 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -94,7 +94,8 @@ check_PROGRAMS = \ | |||
94 | test_testbed_api_testbed_run_topologyrandom \ | 94 | test_testbed_api_testbed_run_topologyrandom \ |
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 | 99 | ||
99 | if ENABLE_TEST_RUN | 100 | if ENABLE_TEST_RUN |
100 | TESTS = \ | 101 | TESTS = \ |
@@ -112,7 +113,8 @@ if ENABLE_TEST_RUN | |||
112 | test_testbed_api_testbed_run_topologyrandom \ | 113 | test_testbed_api_testbed_run_topologyrandom \ |
113 | test_testbed_api_testbed_run_topologyline \ | 114 | test_testbed_api_testbed_run_topologyline \ |
114 | test_testbed_api_testbed_run_topologyclique \ | 115 | test_testbed_api_testbed_run_topologyclique \ |
115 | test_testbed_api_testbed_run_topologyring | 116 | test_testbed_api_testbed_run_topologyring \ |
117 | test_testbed_api_testbed_run_topologysmallworldring | ||
116 | endif | 118 | endif |
117 | 119 | ||
118 | test_testbed_api_hosts_SOURCES = \ | 120 | test_testbed_api_hosts_SOURCES = \ |
@@ -210,10 +212,17 @@ test_testbed_api_testbed_run_topologyring_LDADD = \ | |||
210 | $(top_builddir)/src/util/libgnunetutil.la \ | 212 | $(top_builddir)/src/util/libgnunetutil.la \ |
211 | libgnunettestbed.la | 213 | libgnunettestbed.la |
212 | 214 | ||
215 | test_testbed_api_testbed_run_topologysmallworldring_SOURCES = \ | ||
216 | test_testbed_api_testbed_run.c | ||
217 | test_testbed_api_testbed_run_topologysmallworldring_LDADD = \ | ||
218 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
219 | libgnunettestbed.la | ||
220 | |||
213 | EXTRA_DIST = \ | 221 | EXTRA_DIST = \ |
214 | test_testbed_api.conf \ | 222 | test_testbed_api.conf \ |
215 | test_testbed_api_testbed_run_topologyring.conf \ | 223 | test_testbed_api_testbed_run_topologyring.conf \ |
216 | test_testbed_api_testbed_run_topologyclique.conf \ | 224 | test_testbed_api_testbed_run_topologyclique.conf \ |
217 | test_testbed_api_testbed_run_topologyline.conf \ | 225 | test_testbed_api_testbed_run_topologyline.conf \ |
218 | test_testbed_api_testbed_run_topologyrandom.conf \ | 226 | test_testbed_api_testbed_run_topologyrandom.conf \ |
227 | test_testbed_api_testbed_run_topologysmallworldring.conf \ | ||
219 | sample_hosts.txt \ No newline at end of file | 228 | sample_hosts.txt \ No newline at end of file |
diff --git a/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf b/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf index 84f338c3e..cd2913832 100644 --- a/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf +++ b/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf | |||
@@ -3,7 +3,6 @@ AUTOSTART = NO | |||
3 | PORT = 12113 | 3 | PORT = 12113 |
4 | ACCEPT_FROM = 127.0.0.1; | 4 | ACCEPT_FROM = 127.0.0.1; |
5 | HOSTNAME = localhost | 5 | HOSTNAME = localhost |
6 | NEIGHBOUR_LIMIT = 100 | ||
7 | MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10 | 6 | MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10 |
8 | OVERLAY_TOPOLOGY = RANDOM | 7 | OVERLAY_TOPOLOGY = RANDOM |
9 | OVERLAY_RANDOM_LINKS = 5 | 8 | OVERLAY_RANDOM_LINKS = 5 |
diff --git a/src/testbed/test_testbed_api_testbed_run_topologysmallworldring.conf b/src/testbed/test_testbed_api_testbed_run_topologysmallworldring.conf new file mode 100644 index 000000000..e16c30832 --- /dev/null +++ b/src/testbed/test_testbed_api_testbed_run_topologysmallworldring.conf | |||
@@ -0,0 +1,80 @@ | |||
1 | [testbed] | ||
2 | AUTOSTART = NO | ||
3 | PORT = 12113 | ||
4 | ACCEPT_FROM = 127.0.0.1; | ||
5 | HOSTNAME = localhost | ||
6 | MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10 | ||
7 | OVERLAY_TOPOLOGY = SMALL_WORLD_RING | ||
8 | OVERLAY_RANDOM_LINKS = 5 | ||
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 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 | } |
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c index d6575adbb..59d95ef3b 100644 --- a/src/testbed/testbed_api_topology.c +++ b/src/testbed/testbed_api_topology.c | |||
@@ -92,6 +92,11 @@ struct TopologyContext | |||
92 | void *op_cls; | 92 | void *op_cls; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * The number of peers | ||
96 | */ | ||
97 | unsigned int num_peers; | ||
98 | |||
99 | /** | ||
95 | * The size of the link array | 100 | * The size of the link array |
96 | */ | 101 | */ |
97 | unsigned int link_array_size; | 102 | unsigned int link_array_size; |
@@ -185,6 +190,97 @@ oprelease_overlay_configure_topology (void *cls) | |||
185 | 190 | ||
186 | 191 | ||
187 | /** | 192 | /** |
193 | * Generates line topology | ||
194 | * | ||
195 | * @param tc the topology context | ||
196 | */ | ||
197 | static void | ||
198 | gen_topo_line (struct TopologyContext *tc) | ||
199 | { | ||
200 | unsigned int cnt; | ||
201 | |||
202 | tc->link_array_size = tc->num_peers - 1; | ||
203 | tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * | ||
204 | tc->link_array_size); | ||
205 | for (cnt=0; cnt < (tc->num_peers - 1); cnt++) | ||
206 | { | ||
207 | tc->link_array[cnt].A = cnt; | ||
208 | tc->link_array[cnt].B = cnt + 1; | ||
209 | tc->link_array[cnt].tc = tc; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | |||
214 | /** | ||
215 | * Generates ring topology | ||
216 | * | ||
217 | * @param tc the topology context | ||
218 | */ | ||
219 | static void | ||
220 | gen_topo_ring (struct TopologyContext *tc) | ||
221 | { | ||
222 | gen_topo_line (tc); | ||
223 | tc->link_array_size++; | ||
224 | tc->link_array = GNUNET_realloc (tc->link_array, | ||
225 | sizeof (struct OverlayLink) * | ||
226 | tc->link_array_size); | ||
227 | tc->link_array[tc->link_array_size - 1].op = NULL; | ||
228 | tc->link_array[tc->link_array_size - 1].tc = tc; | ||
229 | tc->link_array[tc->link_array_size - 1].A = tc->num_peers - 1; | ||
230 | tc->link_array[tc->link_array_size - 1].B = 0; | ||
231 | } | ||
232 | |||
233 | |||
234 | /** | ||
235 | * Generates ring topology | ||
236 | * | ||
237 | * @param tc the topology context | ||
238 | * @param links the number of random links to establish | ||
239 | * @param append GNUNET_YES to add links to existing link array; GNUNET_NO to | ||
240 | * create a new link array | ||
241 | */ | ||
242 | static void | ||
243 | gen_topo_random (struct TopologyContext *tc, unsigned int links, int append) | ||
244 | { | ||
245 | unsigned int cnt; | ||
246 | unsigned int index; | ||
247 | uint32_t A_rand; | ||
248 | uint32_t B_rand; | ||
249 | |||
250 | if (GNUNET_YES == append) | ||
251 | { | ||
252 | GNUNET_assert ((0 < tc->link_array_size) && (NULL != tc->link_array)); | ||
253 | index = tc->link_array_size; | ||
254 | tc->link_array_size += links; | ||
255 | tc->link_array = GNUNET_realloc (tc->link_array, | ||
256 | sizeof (struct OverlayLink) * | ||
257 | tc->link_array_size); | ||
258 | } | ||
259 | else | ||
260 | { | ||
261 | GNUNET_assert ((0 == tc->link_array_size) && (NULL == tc->link_array)); | ||
262 | index = 0; | ||
263 | tc->link_array_size = links; | ||
264 | tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * | ||
265 | tc->link_array_size); | ||
266 | } | ||
267 | for (cnt = 0; cnt < links; cnt++) | ||
268 | { | ||
269 | do { | ||
270 | A_rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
271 | tc->num_peers); | ||
272 | B_rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
273 | tc->num_peers); | ||
274 | } while (A_rand == B_rand); | ||
275 | tc->link_array[index + cnt].op = NULL; | ||
276 | tc->link_array[index + cnt].A = A_rand; | ||
277 | tc->link_array[index + cnt].B = B_rand; | ||
278 | tc->link_array[index + cnt].tc = tc; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | |||
283 | /** | ||
188 | * Configure overall network topology to have a particular shape. | 284 | * Configure overall network topology to have a particular shape. |
189 | * | 285 | * |
190 | * @param op_cls closure argument to give with the operation event | 286 | * @param op_cls closure argument to give with the operation event |
@@ -264,50 +360,26 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, | |||
264 | c = peers[0]->controller; | 360 | c = peers[0]->controller; |
265 | tc = GNUNET_malloc (sizeof (struct TopologyContext)); | 361 | tc = GNUNET_malloc (sizeof (struct TopologyContext)); |
266 | tc->peers = peers; | 362 | tc->peers = peers; |
363 | tc->num_peers = num_peers; | ||
267 | tc->op_cls = op_cls; | 364 | tc->op_cls = op_cls; |
268 | switch (topo) | 365 | switch (topo) |
269 | { | 366 | { |
270 | case GNUNET_TESTBED_TOPOLOGY_LINE: | 367 | case GNUNET_TESTBED_TOPOLOGY_LINE: |
368 | gen_topo_line (tc); | ||
369 | break; | ||
271 | case GNUNET_TESTBED_TOPOLOGY_RING: | 370 | case GNUNET_TESTBED_TOPOLOGY_RING: |
272 | tc->link_array_size = | 371 | gen_topo_ring (tc); |
273 | (GNUNET_TESTBED_TOPOLOGY_LINE == topo) | ||
274 | ? (num_peers - 1) : num_peers; | ||
275 | tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * | ||
276 | tc->link_array_size); | ||
277 | for (cnt=0; cnt < (num_peers - 1); cnt++) | ||
278 | { | ||
279 | tc->link_array[cnt].A = cnt; | ||
280 | tc->link_array[cnt].B = cnt + 1; | ||
281 | tc->link_array[cnt].tc = tc; | ||
282 | } | ||
283 | if (GNUNET_TESTBED_TOPOLOGY_RING == topo) | ||
284 | { | ||
285 | tc->link_array[cnt].A = num_peers - 1; | ||
286 | tc->link_array[cnt].B = 0; | ||
287 | tc->link_array[cnt].tc = tc; | ||
288 | cnt++; | ||
289 | } | ||
290 | GNUNET_assert (cnt == tc->link_array_size); | ||
291 | break; | 372 | break; |
292 | case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI: | 373 | case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI: |
293 | tc->link_array_size = va_arg (va, unsigned int); | 374 | gen_topo_random (tc, |
294 | tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * | 375 | va_arg (va, unsigned int), |
295 | tc->link_array_size); | 376 | GNUNET_NO); |
296 | for (cnt = 0; cnt < tc->link_array_size; cnt++) | 377 | break; |
297 | { | 378 | case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING: |
298 | uint32_t A_rand; | 379 | gen_topo_ring (tc); |
299 | uint32_t B_rand; | 380 | gen_topo_random (tc, |
300 | 381 | va_arg (va, unsigned int), | |
301 | do { | 382 | GNUNET_YES); |
302 | A_rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
303 | num_peers); | ||
304 | B_rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
305 | num_peers); | ||
306 | } while (A_rand == B_rand); | ||
307 | tc->link_array[cnt].A = A_rand; | ||
308 | tc->link_array[cnt].B = B_rand; | ||
309 | tc->link_array[cnt].tc = tc; | ||
310 | } | ||
311 | break; | 383 | break; |
312 | case GNUNET_TESTBED_TOPOLOGY_CLIQUE: | 384 | case GNUNET_TESTBED_TOPOLOGY_CLIQUE: |
313 | tc->link_array_size = num_peers * (num_peers - 1); | 385 | tc->link_array_size = num_peers * (num_peers - 1); |