- validate client generated PIDs
[oweals/gnunet.git] / src / mesh / test_mesh_small.c
index 974b63590aa686ce846580c8b35d4934b3d60490..d78d12117decad50d96a99a4f14b437453c06879 100644 (file)
@@ -275,7 +275,7 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
 }
 
-size_t
+static size_t
 tmt_rdy (void *cls, size_t size, void *buf);
 
 static void
@@ -284,7 +284,7 @@ data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct GNUNET_MESH_TransmitHandle *th;
   if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
     return;
-  th = GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO, 0,
+  th = GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO,
                                     GNUNET_TIME_UNIT_FOREVER_REL, &d2->id,
                                     sizeof (struct GNUNET_MessageHeader),
                                     &tmt_rdy, (void *) 1L);
@@ -380,25 +380,25 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
     }
     if (test == MULTICAST && peers_responded < 2)
       return GNUNET_OK;
-    if (test == SPEED_ACK)
+    if (test == SPEED_ACK || test == SPEED)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               " received ack %u\n", data_ack);
-      GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, 0,
+      GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO,
                                         GNUNET_TIME_UNIT_FOREVER_REL, sender,
                                         sizeof (struct GNUNET_MessageHeader),
                                         &tmt_rdy, (void *) 1L);
-      if (data_ack < 1000)
+      if (data_ack < 1000 && test != SPEED)
         return GNUNET_OK;
       end_time = GNUNET_TIME_absolute_get();
       total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
       FPRINTF (stderr, "\nTest time %llu ms\n",
                (unsigned long long) total_time.rel_value);
       FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
-               4000.0 / total_time.rel_value);
-      FPRINTF (stderr, "Test throughput: %f packets/s\n",
-               1000000.0 / total_time.rel_value);
-      GAUGER ("MESH", "Tunnel 5 peers", 1000000.0 / total_time.rel_value,
+               4 * 1000.0 / total_time.rel_value); // 4bytes * ms
+      FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
+               1000.0 * 1000.0 / total_time.rel_value); // 1000 packets * ms
+      GAUGER ("MESH", "Tunnel 5 peers", 1000.0 * 1000.0 / total_time.rel_value,
               "packets/s");
     }
     GNUNET_assert (tunnel == t);
@@ -412,9 +412,9 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
                 client);
     ok++;
     GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
-    if (SPEED != test)
+    if (SPEED != test || 1002 == ok)
     {
-      GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, 0,
+      GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO,
                                         GNUNET_TIME_UNIT_FOREVER_REL, sender,
                                         sizeof (struct GNUNET_MessageHeader),
                                         &tmt_rdy, (void *) 1L);
@@ -606,7 +606,7 @@ ch (void *cls, const struct GNUNET_PeerIdentity *peer,
     data_received = 0;
     data_sent = 0;
     start_time = GNUNET_TIME_absolute_get();
-    GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO, 0,
+    GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO,
                                        GNUNET_TIME_UNIT_FOREVER_REL, dest,
                                        sizeof (struct GNUNET_MessageHeader),
                                        &tmt_rdy, (void *) 1L);
@@ -678,13 +678,13 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                 GNUNET_i2s (&d3->id));
   }
 #endif
-  h1 = GNUNET_MESH_connect (d1->cfg, 5, (void *) 1L, NULL, &tunnel_cleaner,
+  h1 = GNUNET_MESH_connect (d1->cfg, (void *) 1L, NULL, &tunnel_cleaner,
                             handlers, &app);
-  h2 = GNUNET_MESH_connect (d2->cfg, 5, (void *) 2L, &incoming_tunnel,
+  h2 = GNUNET_MESH_connect (d2->cfg, (void *) 2L, &incoming_tunnel,
                             &tunnel_cleaner, handlers, &app);
   if (test == MULTICAST)
   {
-    h3 = GNUNET_MESH_connect (d3->cfg, 5, (void *) 3L, &incoming_tunnel,
+    h3 = GNUNET_MESH_connect (d3->cfg, (void *) 3L, &incoming_tunnel,
                               &tunnel_cleaner, handlers, &app);
   }
   t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 1L);
@@ -827,12 +827,12 @@ run (void *cls, char *const *args, const char *cfgfile,
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Starting daemons.\n");
-  GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing",
+  GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing_old",
                                          "use_progressbars", "YES");
 #endif
 
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing",
+      GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing_old",
                                              "num_peers", &num_peers))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -850,7 +850,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   }
 
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (testing_cfg, "testing",
+      GNUNET_CONFIGURATION_get_value_string (testing_cfg, "testing_old",
                                              "topology_output_file",
                                              &topology_file))
   {
@@ -985,13 +985,13 @@ main (int argc, char *argv[])
     * 1 incoming tunnel (@dest)
     * 1 connected peer (@orig)
     * 1000 received data packet (@dest)
+    * 1received data packet (@orig)
     * 1 received tunnel destroy (@dest)
     * _________________________________
-    * 5 x ok expected per peer
     */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
     test = SPEED;
-    ok_goal = 1003;
+    ok_goal = 1004;
   }
   else
   {