more minor fixes and better measurements
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 23 Dec 2019 15:56:18 +0000 (00:56 +0900)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 23 Dec 2019 15:56:18 +0000 (00:56 +0900)
src/transport/test_communicator_basic.c

index 176996b9d6f5ec8fcfee1ca930e332e14190d086..d7622a2ccb2da0204bf0821a618b7115c274c126 100644 (file)
@@ -64,15 +64,15 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *my_tc;
 
 #define LONG_MESSAGE_SIZE 32000
 
-#define SHORT_BURST_SECONDS 2
+#define BURST_PACKETS 5000
 
-#define LONG_BURST_SECONDS 2
+#define BURST_RUNS 1
 
 #define SHORT_BURST_WINDOW \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,SHORT_BURST_SECONDS)
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,5)
 
 #define LONG_BURST_WINDOW \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,SHORT_BURST_SECONDS)
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2)
 
 #define BURST_SHORT 0
 
@@ -80,9 +80,8 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *my_tc;
 
 #define SIZE_CHECK 2
 
-#define MAX_BUF_LEN 1
 
-static int buf_len = 0;
+static int num_sent = 0;
 
 static uint32_t ack = 0;
 
@@ -187,12 +186,18 @@ size_test (void *cls)
                                                           payload,
                                                           ack);
     GNUNET_free (payload);
+    ack += 5;
+    if (ack < 64000)
+      GNUNET_SCHEDULER_add_now (&size_test, NULL);
+    else
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                    &size_test, NULL);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Size packet test done.\n");
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "#packets: %lu -- latency: %lu\n",
+              "#packets: %lu -- latency: %lu microseconds\n",
               num_received,
               avg_latency);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -208,32 +213,32 @@ long_test (void *cls)
   struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_duration (
     start_long);
   char *payload;
-  if (LONG_BURST_WINDOW.rel_value_us > duration.rel_value_us)
+  if (num_sent < BURST_PACKETS)
   {
-    //FIXME: Not sure how aggressive we should be here, our transport does not
-    //implement congestion control or flow control... (also for the other three
-    if (buf_len < MAX_BUF_LEN)
-    {
-      payload = make_payload (LONG_MESSAGE_SIZE);
-      GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
-                                                            payload,
-                                                            LONG_MESSAGE_SIZE);
-      buf_len++;
-      GNUNET_free (payload);
+    payload = make_payload (LONG_MESSAGE_SIZE);
+    GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
+                                                          payload,
+                                                          LONG_MESSAGE_SIZE);
+    num_sent++;
+    GNUNET_free (payload);
+    if (num_sent < BURST_PACKETS)
       GNUNET_SCHEDULER_add_now (&long_test, NULL);
-    }
+    if (num_sent == BURST_PACKETS)
+      GNUNET_SCHEDULER_add_delayed (LONG_BURST_WINDOW,
+                                    &long_test, NULL);
     return;
   }
+  duration = GNUNET_TIME_absolute_get_duration (start_long);
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Long size packet test done.\n");
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "goodput: %lu b/s -- #packets: %lu -- latency: %lu\n",
-              (LONG_MESSAGE_SIZE * num_received) / LONG_BURST_SECONDS,
+              "goodput: %lu kb/s -- #packets: %lu -- latency: %lu microseconds\n",
+              (LONG_MESSAGE_SIZE * num_received) / (duration.rel_value_us / 1000),
               num_received,
               avg_latency);
   ack = 10;
   num_received = 0;
-  buf_len = 0;
+  num_sent = 0;
   avg_latency = 0;
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &size_test, NULL);
 }
@@ -242,33 +247,34 @@ long_test (void *cls)
 static void
 short_test (void *cls)
 {
-  struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_duration (
-    start_short);
+  struct GNUNET_TIME_Relative duration;
   char *payload;
-  if (SHORT_BURST_WINDOW.rel_value_us > duration.rel_value_us)
+  if (num_sent < BURST_PACKETS)
   {
-    if (buf_len < MAX_BUF_LEN)
-    {
-      payload = make_payload (SHORT_MESSAGE_SIZE);
-      GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
-                                                            payload,
-                                                            SHORT_MESSAGE_SIZE);
-      buf_len++;
-      GNUNET_free (payload);
+    payload = make_payload (SHORT_MESSAGE_SIZE);
+    GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
+                                                          payload,
+                                                          SHORT_MESSAGE_SIZE);
+    num_sent++;
+    GNUNET_free (payload);
+    if (num_sent < BURST_PACKETS)
       GNUNET_SCHEDULER_add_now (&short_test, NULL);
-    }
+    if (num_sent == BURST_PACKETS)
+      GNUNET_SCHEDULER_add_delayed (SHORT_BURST_WINDOW,
+                                    &short_test, NULL);
     return;
   }
+  duration = GNUNET_TIME_absolute_get_duration (start_short);
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Short size packet test done.\n");
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "goodput: %lu b/s -- #packets: %lu -- latency: %lu\n",
-              (SHORT_MESSAGE_SIZE * num_received) / SHORT_BURST_SECONDS,
+              "goodput: %lu kb/s -- #packets: %lu -- latency: %lu microseconds\n",
+              (SHORT_MESSAGE_SIZE * num_received) / (duration.rel_value_us / 1000),
               num_received,
               avg_latency);
   start_long = GNUNET_TIME_absolute_get ();
   phase = BURST_LONG;
-  buf_len = 0;
+  num_sent = 0;
   avg_latency = 0;
   num_received = 0;
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &long_test, NULL);
@@ -298,7 +304,6 @@ add_queue_cb (void *cls,
        "Queue established, starting test...\n");
   start_short = GNUNET_TIME_absolute_get ();
   my_tc = tc_queue;
-  buf_len = 0;
   phase = BURST_SHORT;
   GNUNET_SCHEDULER_add_now (&short_test, tc_queue);
 }
@@ -346,9 +351,6 @@ incoming_message_cb (void *cls,
     GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len);
     num_received++;
     update_avg_latency (payload);
-    if (buf_len == MAX_BUF_LEN)
-      GNUNET_SCHEDULER_add_now (&short_test, NULL);
-    buf_len--;
   }
   else if (phase == BURST_LONG)
   {
@@ -356,26 +358,11 @@ incoming_message_cb (void *cls,
       return; // Ignore
     num_received++;
     update_avg_latency (payload);
-    if (buf_len == MAX_BUF_LEN)
-      GNUNET_SCHEDULER_add_now (&long_test, NULL);
-    buf_len--;
   }
   else         // if (phase == SIZE_CHECK) {
   {
-    // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-    //          "Receiving payload with size %lu...\n", payload_len);
-    if (ack != payload_len)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Error receiving message, corrupted.\n");
-      ret = 1;
-      GNUNET_SCHEDULER_shutdown ();
-      return;
-    }
     num_received++;
     update_avg_latency (payload);
-    ack += 5; // Next expected message size
-    GNUNET_SCHEDULER_add_now (&size_test, NULL);
   }
 }
 
@@ -390,6 +377,7 @@ run (void *cls)
 {
   ret = 0;
   num_received = 0;
+  num_sent = 0;
   for (int i = 0; i < NUM_PEERS; i++)
   {
     tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (