From aa317bd7953190ac0b0ceef02ba3f36047982a6c Mon Sep 17 00:00:00 2001 From: Carlo von lynX Date: Sat, 6 Aug 2016 13:59:03 +0000 Subject: [PATCH] testbed: STAR topology (SCNR) --- src/include/gnunet_testbed_service.h | 5 ++ src/testbed/Makefile.am | 9 ++++ src/testbed/generate-underlay-topology.c | 1 + ..._testbed_api_testbed_run_topologystar.conf | 4 ++ src/testbed/testbed_api_topology.c | 53 +++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 src/testbed/test_testbed_api_testbed_run_topologystar.conf diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h index 781dc0441..bc4be0140 100644 --- a/src/include/gnunet_testbed_service.h +++ b/src/include/gnunet_testbed_service.h @@ -980,6 +980,11 @@ enum GNUNET_TESTBED_TopologyOption */ GNUNET_TESTBED_TOPOLOGY_RING, + /** + * Star topology. No options. + */ + GNUNET_TESTBED_TOPOLOGY_STAR, + /** * 2-d torus. No options. */ diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index 9c1bfcce6..16fe27fc0 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am @@ -142,6 +142,7 @@ check_PROGRAMS = \ test_testbed_api_topology_clique \ test_testbed_api_testbed_run_topologyrandom \ test_testbed_api_testbed_run_topologyline \ + test_testbed_api_testbed_run_topologystar \ test_testbed_api_testbed_run_topologyclique \ test_testbed_api_testbed_run_topologyring \ test_testbed_api_testbed_run_topologysmallworldring \ @@ -176,6 +177,7 @@ if ENABLE_TEST_RUN test_testbed_api_topology_clique \ test_testbed_api_testbed_run_topologyrandom \ test_testbed_api_testbed_run_topologyline \ + test_testbed_api_testbed_run_topologystar \ test_testbed_api_testbed_run_topologyclique \ test_testbed_api_testbed_run_topologyring \ test_testbed_api_testbed_run_topology2dtorus \ @@ -282,6 +284,12 @@ test_testbed_api_testbed_run_topologyline_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ libgnunettestbed.la +test_testbed_api_testbed_run_topologystar_SOURCES = \ + test_testbed_api_testbed_run.c +test_testbed_api_testbed_run_topologystar_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la \ + libgnunettestbed.la + test_testbed_api_testbed_run_topologyclique_SOURCES = \ test_testbed_api_testbed_run.c test_testbed_api_testbed_run_topologyclique_LDADD = \ @@ -374,6 +382,7 @@ EXTRA_DIST = \ test_testbed_api_test_timeout.conf \ test_testbed_api_template.conf \ test_testbed_api_testbed_run_topologyring.conf \ + test_testbed_api_testbed_run_topologystar.conf \ test_testbed_api_testbed_run_topologyclique.conf \ test_testbed_api_testbed_run_topologyline.conf \ test_testbed_api_testbed_run_topologyrandom.conf \ diff --git a/src/testbed/generate-underlay-topology.c b/src/testbed/generate-underlay-topology.c index 22fe98e33..36580a2a3 100644 --- a/src/testbed/generate-underlay-topology.c +++ b/src/testbed/generate-underlay-topology.c @@ -298,6 +298,7 @@ run (void *cls, char *const *args, const char *cfgfile, { case GNUNET_TESTBED_TOPOLOGY_LINE: case GNUNET_TESTBED_TOPOLOGY_RING: + case GNUNET_TESTBED_TOPOLOGY_STAR: case GNUNET_TESTBED_TOPOLOGY_CLIQUE: case GNUNET_TESTBED_TOPOLOGY_2D_TORUS: GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL, diff --git a/src/testbed/test_testbed_api_testbed_run_topologystar.conf b/src/testbed/test_testbed_api_testbed_run_topologystar.conf new file mode 100644 index 000000000..13f8d1784 --- /dev/null +++ b/src/testbed/test_testbed_api_testbed_run_topologystar.conf @@ -0,0 +1,4 @@ +@INLINE@ test_testbed_api_template.conf + +[testbed] +OVERLAY_TOPOLOGY = STAR diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c index 1f7d11b27..b7722b9c7 100644 --- a/src/testbed/testbed_api_topology.c +++ b/src/testbed/testbed_api_topology.c @@ -285,6 +285,11 @@ const char *topology_strings[] = { */ "RING", + /** + * Star topology. No options. + */ + "STAR", + /** * 2-d torus. No options. */ @@ -315,6 +320,11 @@ const char *topology_strings[] = { */ "LINE", + /** + * Star topology. No options. + */ + "STAR", + /** * Read a topology from a given file. Followed by the name of the file (const char *). */ @@ -539,6 +549,43 @@ gen_topo_line (struct TopologyContext *tc) } +/** + * Generates star topology + * + * @param tc the topology context + */ +static void +gen_topo_star (struct TopologyContext *tc) +{ + unsigned int cnt; + + tc->link_array_size = tc->num_peers - 1; + switch (tc->type) + { + case TOPOLOGYCONTEXT_TYPE_OVERLAY: + { + struct TopologyContextOverlay *overlay; + + overlay = &tc->u.overlay; + overlay->link_array = + GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size); + } + break; + case TOPOLOGYCONTEXT_TYPE_UNDERLAY: + { + struct TopologyContextUnderlay *underlay; + + underlay = &tc->u.underlay; + underlay->link_array = + GNUNET_malloc (sizeof (struct UnderlayLink) * tc->link_array_size); + } + break; + } + for (cnt = tc->link_array_size; cnt; cnt--) + make_link (0, 0, cnt, tc); +} + + /** * Generates ring topology * @@ -1278,6 +1325,9 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, case GNUNET_TESTBED_TOPOLOGY_LINE: gen_topo_line (tc); break; + case GNUNET_TESTBED_TOPOLOGY_STAR: + gen_topo_star (tc); + break; case GNUNET_TESTBED_TOPOLOGY_RING: gen_topo_ring (tc); break; @@ -1492,6 +1542,9 @@ GNUNET_TESTBED_underlay_construct_ (int num_peers, case GNUNET_TESTBED_TOPOLOGY_LINE: gen_topo_line (&tc); break; + case GNUNET_TESTBED_TOPOLOGY_STAR: + gen_topo_star (&tc); + break; case GNUNET_TESTBED_TOPOLOGY_RING: gen_topo_ring (&tc); break; -- 2.25.1