Browse Source

testbed: STAR topology (SCNR)

Carlo von lynX 7 years ago
parent
commit
aa317bd795

+ 5 - 0
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.
    */

+ 9 - 0
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 \

+ 1 - 0
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,

+ 4 - 0
src/testbed/test_testbed_api_testbed_run_topologystar.conf

@@ -0,0 +1,4 @@
+@INLINE@ test_testbed_api_template.conf
+
+[testbed]
+OVERLAY_TOPOLOGY = STAR

+ 53 - 0
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;