gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37577 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r37577 - gnunet/src/transport
Date: Sun, 24 Jul 2016 17:51:17 +0200

Author: grothoff
Date: 2016-07-24 17:51:16 +0200 (Sun, 24 Jul 2016)
New Revision: 37577

Modified:
   gnunet/src/transport/
   gnunet/src/transport/test_quota_compliance.c
   gnunet/src/transport/test_transport_defaults.conf
   gnunet/src/transport/transport-testing-send.c
Log:
convert last test to new send api

Index: gnunet/src/transport
===================================================================
--- gnunet/src/transport        2016-07-24 14:54:22 UTC (rev 37576)
+++ gnunet/src/transport        2016-07-24 15:51:16 UTC (rev 37577)

Property changes on: gnunet/src/transport
___________________________________________________________________
Modified: svn:ignore
## -1,3 +1,148 ##
+test_transport_api_timeout_wlan.trs
+test_transport_api_timeout_wlan.log
+test_transport_api_timeout_unix.trs
+test_transport_api_timeout_unix.log
+test_transport_api_timeout_udp.trs
+test_transport_api_timeout_udp.log
+test_transport_api_timeout_tcp.trs
+test_transport_api_timeout_tcp.log
+test_transport_api_timeout_https.trs
+test_transport_api_timeout_https.log
+test_transport_api_timeout_http.trs
+test_transport_api_timeout_http.log
+test_transport_api_timeout_bluetooth.trs
+test_transport_api_timeout_bluetooth.log
+test_transport_api_slow_ats.trs
+test_transport_api_slow_ats.log
+test_quota_compliance_unix_asymmetric.trs
+test_quota_compliance_unix_asymmetric.log
+test_quota_compliance_unix.trs
+test_quota_compliance_unix.log
+test_quota_compliance_udp.trs
+test_quota_compliance_udp.log
+test_quota_compliance_tcp_asymmetric.trs
+test_quota_compliance_https_asymmetric.trs
+test_quota_compliance_https_asymmetric.log
+test_quota_compliance_https.trs
+test_quota_compliance_https.log
+test_quota_compliance_http_asymmetric.trs
+test_quota_compliance_http_asymmetric.log
+test_quota_compliance_http.trs
+test_quota_compliance_http.log
+test-suite.log
+test_transport_testing_startstop.trs
+test_transport_testing_startstop.log
+test_transport_testing_restart.trs
+test_transport_testing_restart.log
+test_transport_testing.trs
+test_transport_testing.log
+test_transport_blacklisting_outbound_bl_plugin.trs
+test_transport_blacklisting_outbound_bl_plugin.log
+test_transport_blacklisting_outbound_bl_full.trs
+test_transport_blacklisting_outbound_bl_full.log
+test_transport_blacklisting_no_bl.trs
+test_transport_blacklisting_no_bl.log
+test_transport_blacklisting_multiple_plugins.trs
+test_transport_blacklisting_multiple_plugins.log
+test_transport_blacklisting_inbound_bl_plugin.trs
+test_transport_blacklisting_inbound_bl_plugin.log
+test_transport_blacklisting_inbound_bl_full.trs
+test_transport_blacklisting_inbound_bl_full.log
+test_transport_api_wlan.trs
+test_transport_api_wlan.log
+test_transport_api_unix_abstract.trs
+test_transport_api_unix_abstract.log
+test_transport_api_unix.trs
+test_transport_api_unix.log
+test_transport_api_udp_nat.trs
+test_transport_api_udp_nat.log
+test_transport_api_udp.trs
+test_transport_api_udp.log
+test_transport_api_tcp_nat.trs
+test_transport_api_tcp_nat.log
+test_transport_api_tcp.trs
+test_transport_api_tcp.log
+test_transport_api_restart_2peers.trs
+test_transport_api_restart_2peers.log
+test_transport_api_restart_1peer.trs
+test_transport_api_restart_1peer.log
+test_transport_api_reliability_wlan.trs
+test_transport_api_reliability_wlan.log
+test_transport_api_reliability_unix.trs
+test_transport_api_reliability_unix.log
+test_transport_api_reliability_udp.trs
+test_transport_api_reliability_udp.log
+test_transport_api_reliability_tcp_nat.trs
+test_transport_api_reliability_tcp_nat.log
+test_transport_api_reliability_tcp.trs
+test_transport_api_reliability_tcp.log
+test_transport_api_reliability_https_xhr.trs
+test_transport_api_reliability_https_xhr.log
+test_transport_api_reliability_https.trs
+test_transport_api_reliability_https.log
+test_transport_api_reliability_bluetooth.trs
+test_transport_api_reliability_bluetooth.log
+test_transport_api_blacklisting_tcp
+test_quota_compliance_tcp_asymmetric.log
+test_quota_compliance_tcp.trs
+test_quota_compliance_tcp.log
+test_transport_api_reliability_http_xhr.trs
+test_transport_api_reliability_http_xhr.log
+test_transport_api_reliability_http.trs
+test_transport_api_reliability_http.log
+test_transport_api_multi.trs
+test_transport_api_multi.log
+test_transport_api_monitor_peers.trs
+test_transport_api_monitor_peers.log
+test_transport_api_manipulation_send_tcp.trs
+test_transport_api_manipulation_send_tcp.log
+test_transport_api_manipulation_recv_tcp.trs
+test_transport_api_manipulation_recv_tcp.log
+test_transport_api_manipulation_cfg.trs
+test_transport_api_manipulation_cfg.log
+test_transport_api_limited_sockets_tcp.trs
+test_transport_api_limited_sockets_tcp.log
+test_transport_api_https.trs
+test_transport_api_https.log
+test_transport_api_http.trs
+test_transport_api_http.log
+test_transport_api_disconnect_tcp.trs
+test_transport_api_disconnect_tcp.log
+test_transport_api_bluetooth.trs
+test_transport_api_bluetooth.log
+test_transport_api_blacklisting_tcp.trs
+test_transport_api_blacklisting_tcp.log
+test_transport_address_switch_udp.trs
+test_transport_address_switch_udp.log
+test_transport_address_switch_tcp.trs
+test_transport_address_switch_tcp.log
+test_transport_address_switch_https.trs
+test_transport_address_switch_https.log
+test_transport_address_switch_http.trs
+test_transport_address_switch_http.log
+test_plugin_wlan.trs
+test_plugin_wlan.log
+test_plugin_unix.trs
+test_plugin_unix.log
+test_plugin_udp.trs
+test_plugin_udp.log
+test_plugin_tcp.trs
+test_plugin_tcp.log
+test_plugin_bluetooth.trs
+test_plugin_bluetooth.log
+q_in_1073741824_q_out_1073741824_test_quota_compliance_unix_asymmetric_peer1.conf
+q_in_1073741824_q_out_1073741824_test_quota_compliance_tcp_asymmetric_peer1.conf
+q_in_1073741824_q_out_1073741824_test_quota_compliance_https_asymmetric_peer1.conf
+q_in_1073741824_q_out_1073741824_test_quota_compliance_http_asymmetric_peer1.conf
+q_in_10000_q_out_10000_test_quota_compliance_unix_peer2.conf
+q_in_10000_q_out_10000_test_quota_compliance_unix_asymmetric_peer2.conf
+q_in_10000_q_out_10000_test_quota_compliance_udp_peer2.conf
+q_in_10000_q_out_10000_test_quota_compliance_tcp_peer2.conf
+q_in_10000_q_out_10000_test_quota_compliance_tcp_asymmetric_peer2.conf
+q_in_10000_q_out_10000_test_quota_compliance_https_peer2.conf
+q_in_10000_q_out_10000_test_quota_compliance_https_asymmetric_peer2.conf
+q_in_10000_q_out_10000_test_quota_compliance_http_peer2.conf
+q_in_10000_q_out_10000_test_quota_compliance_http_asymmetric_peer2.conf
 test_transport_api_slow_ats
 test_transport_api_reliability_https_xhr
 test_transport_api_reliability_http_xhr
Modified: gnunet/src/transport/test_quota_compliance.c
===================================================================
--- gnunet/src/transport/test_quota_compliance.c        2016-07-24 14:54:22 UTC 
(rev 37576)
+++ gnunet/src/transport/test_quota_compliance.c        2016-07-24 15:51:16 UTC 
(rev 37577)
@@ -32,20 +32,13 @@
 /**
  * Testcase timeout
  */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 480)
 
-/**
- * How long until we give up on transmitting the message?
- */
-#define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 20)
+#define DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 80)
 
-#define DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
 
-
 static struct GNUNET_SCHEDULER_Task *measure_task;
 
-struct GNUNET_TRANSPORT_TransmitHandle *th;
-
 static char *gen_cfgs[2];
 
 static unsigned long long quota_in[] = { 10000, 10000 };
@@ -60,25 +53,10 @@
  * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise
  * messages may be dropped even for a reliable transport.
  */
-#define TOTAL_MSGS (1024 * 2)
+#define TOTAL_MSGS (1024 * 32)
 
-#define MTYPE 12345
+static unsigned long long total_bytes_recv;
 
-GNUNET_NETWORK_STRUCT_BEGIN
-struct TestMessage
-{
-  struct GNUNET_MessageHeader header;
-
-  uint32_t num GNUNET_PACKED;
-};
-GNUNET_NETWORK_STRUCT_END
-
-static int msg_scheduled;
-
-static int msg_sent;
-
-static unsigned long long total_bytes_sent;
-
 static struct GNUNET_TIME_Absolute start_time;
 
 
@@ -89,24 +67,24 @@
   unsigned long long datarate;
 
   delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
-  datarate = (total_bytes_sent * 1000 * 1000) / delta;
-
+  datarate = (total_bytes_recv * 1000 * 1000) / delta;
+  
   FPRINTF (stderr,
            "Throughput was %llu b/s\n",
            datarate);
-
-  if (datarate > quota_in[1])
+  ccc->global_ret = GNUNET_OK;
+  if (datarate > 1.1 * quota_in[1])
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Datarate of %llu b/s higher than allowed inbound quota of 
%llu b/s\n",
+                "Datarate of %llu b/s significantly higher than allowed 
inbound quota of %llu b/s\n",
                 datarate,
                 quota_in[1]);
     ccc->global_ret = GNUNET_SYSERR;
   }
-  if (datarate > quota_out[0])
+  if (datarate > 1.1 * quota_out[0])
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Datarate of %llu b/s higher than allowed outbound quota of 
%llu b/s\n",
+                "Datarate of %llu b/s significantly higher than allowed 
outbound quota of %llu b/s\n",
                 datarate,
                 quota_out[0]);
     ccc->global_ret = GNUNET_SYSERR;
@@ -130,22 +108,18 @@
     GNUNET_SCHEDULER_cancel (measure_task);
     measure_task = NULL;
   }
-  if (NULL != th)
-  {
-    GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
-    th = NULL;
-  }
   report ();
 }
 
 
-static unsigned int
+static size_t
 get_size (unsigned int iter)
 {
-  unsigned int ret;
+  size_t ret;
 
-  ret = (iter * iter * iter);
-  return sizeof (struct TestMessage) + (ret % 60000);
+  ret = (iter * iter * iter) % 60000;
+  ret += sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage);
+  return ret;
 }
 
 
@@ -155,11 +129,12 @@
                 const struct GNUNET_PeerIdentity *sender,
                 const struct GNUNET_MessageHeader *message)
 {
-  const struct TestMessage *hdr;
+  const struct GNUNET_TRANSPORT_TESTING_TestMessage *hdr;
 
-  hdr = (const struct TestMessage *) message;
-  if (MTYPE != ntohs (message->type))
+  hdr = (const struct GNUNET_TRANSPORT_TESTING_TestMessage *) message;
+  if (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs (message->type))
     return;
+  total_bytes_recv += ntohs (message->size);
 
   {
     char *ps = GNUNET_strdup (GNUNET_i2s (&receiver->id));
@@ -176,124 +151,7 @@
 }
 
 
-static size_t
-notify_ready (void *cls,
-              size_t size,
-              void *buf)
-{
-  static int n;
-  char *cbuf = buf;
-  struct TestMessage hdr;
-  unsigned int s;
-  unsigned int ret;
-
-  th = NULL;
-  if (NULL == buf)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Timeout occurred while waiting for transmit_ready for message 
%u of %u\n",
-                msg_scheduled, TOTAL_MSGS);
-    GNUNET_SCHEDULER_shutdown ();
-    ccc->global_ret = GNUNET_SYSERR;
-    return 0;
-  }
-
-  ret = 0;
-  s = get_size (n);
-  GNUNET_assert (size >= s);
-  GNUNET_assert (buf != NULL);
-  cbuf = buf;
-  do
-  {
-    hdr.header.size = htons (s);
-    hdr.header.type = htons (MTYPE);
-    hdr.num = htonl (n);
-    msg_sent = n;
-    GNUNET_memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage));
-    ret += sizeof (struct TestMessage);
-    memset (&cbuf[ret], n, s - sizeof (struct TestMessage));
-    ret += s - sizeof (struct TestMessage);
-#if VERBOSE
-    if (n % 5000 == 0)
-    {
-#endif
-      char *receiver_s = GNUNET_strdup (GNUNET_i2s (&ccc->p[0]->id));
-
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  "Sending message %u of size %u from peer %u (`%4s') -> peer 
%u (`%s') !\n",
-                  n, s,
-                  ccc->p[1]->no,
-                  GNUNET_i2s (&ccc->p[1]->id),
-                  ccc->p[0]->no,
-                  receiver_s);
-      GNUNET_free (receiver_s);
-#if 0
-    }
-#endif
-    n++;
-    s = get_size (n);
-    if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
-      break;                    /* sometimes pack buffer full, sometimes not */
-  }
-  while (size - ret >= s);
-  if (n < TOTAL_MSGS)
-  {
-    if (th == NULL)
-      th = GNUNET_TRANSPORT_notify_transmit_ready (ccc->p[1]->th,
-                                                   &ccc->p[0]->id,
-                                                   s,
-                                                   TIMEOUT_TRANSMIT,
-                                                   &notify_ready,
-                                                   NULL);
-    msg_scheduled = n;
-  }
-  if (n % 5000 == 0)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Returning total message block of size %u\n",
-                ret);
-  }
-  total_bytes_sent += ret;
-  if (n == TOTAL_MSGS)
-  {
-    FPRINTF (stderr, "%s",  "\n");
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "All messages sent\n");
-  }
-  return ret;
-}
-
-
 static void
-notify_disconnect (void *cls,
-                   struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
-                   const struct GNUNET_PeerIdentity *other)
-{
-  GNUNET_TRANSPORT_TESTING_log_disconnect (cls,
-                                           me,
-                                           other);
-  if (th != NULL)
-  {
-    GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
-    th = NULL;
-  }
-}
-
-
-static void
-sendtask ()
-{
-  start_time = GNUNET_TIME_absolute_get ();
-  th = GNUNET_TRANSPORT_notify_transmit_ready (ccc->p[1]->th,
-                                               &ccc->p[0]->id,
-                                               get_size (0),
-                                               TIMEOUT_TRANSMIT,
-                                               &notify_ready,
-                                               NULL);
-}
-
-
-static void
 measure (void *cls)
 {
   static int counter;
@@ -316,11 +174,18 @@
 static void
 start_task (void *cls)
 {
+  static struct GNUNET_TRANSPORT_TESTING_SendClosure sc = {
+    .num_messages = TOTAL_MSGS,
+    .get_size_cb = &get_size
+  };
+
+  sc.ccc = ccc;
   measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
                                                &measure,
                                                NULL);
-  GNUNET_SCHEDULER_add_now (&sendtask,
-                            NULL);
+  start_time = GNUNET_TIME_absolute_get ();
+  GNUNET_SCHEDULER_add_now (&GNUNET_TRANSPORT_TESTING_simple_send,
+                            &sc);
 }
 
 
@@ -386,7 +251,7 @@
     .config_file = "test_quota_compliance_data.conf",
     .rec = &notify_receive,
     .nc = &GNUNET_TRANSPORT_TESTING_log_connect,
-    .nd = &notify_disconnect,
+    .nd = &GNUNET_TRANSPORT_TESTING_log_disconnect,
     .shutdown_task = &custom_shutdown,
     .timeout = TIMEOUT
   };
@@ -429,7 +294,8 @@
 
 
 int
-main (int argc, char *argv[])
+main (int argc,
+      char *argv[])
 {
   if (GNUNET_OK !=
       GNUNET_TRANSPORT_TESTING_main (2,

Modified: gnunet/src/transport/test_transport_defaults.conf
===================================================================
--- gnunet/src/transport/test_transport_defaults.conf   2016-07-24 14:54:22 UTC 
(rev 37576)
+++ gnunet/src/transport/test_transport_defaults.conf   2016-07-24 15:51:16 UTC 
(rev 37577)
@@ -7,7 +7,7 @@
 TIMEOUT = 300 s
 
 [transport]
-#PREFIX = valgrind 
+# PREFIX = valgrind 
 
 [nat]
 DISABLEV6 = NO

Modified: gnunet/src/transport/transport-testing-send.c
===================================================================
--- gnunet/src/transport/transport-testing-send.c       2016-07-24 14:54:22 UTC 
(rev 37576)
+++ gnunet/src/transport/transport-testing-send.c       2016-07-24 15:51:16 UTC 
(rev 37577)
@@ -27,7 +27,7 @@
 /**
  * Acceptable transmission delay.
  */
-#define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 5)
+#define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 30)
 
 
 static size_t




reply via email to

[Prev in Thread] Current Thread [Next in Thread]