gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r13360 - gnunet/src/transport
Date: Fri, 22 Oct 2010 13:45:27 +0200

Author: wachs
Date: 2010-10-22 13:45:27 +0200 (Fri, 22 Oct 2010)
New Revision: 13360

Modified:
   gnunet/src/transport/test_quota_compliance.c
Log:


Modified: gnunet/src/transport/test_quota_compliance.c
===================================================================
--- gnunet/src/transport/test_quota_compliance.c        2010-10-22 09:59:07 UTC 
(rev 13359)
+++ gnunet/src/transport/test_quota_compliance.c        2010-10-22 11:45:27 UTC 
(rev 13360)
@@ -47,11 +47,16 @@
  */
 #define TOTAL_MSGS (10000 * 2)
 
+#define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 20)
+#define MEASUREMENT_MSG_SIZE 1024
+#define MEASUREMENT_MSG_SIZE_BIG 32768
+
 /**
- * How long until we give up on transmitting the message?
+ * Testcase timeout
  */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 200)
 
+
 #define MTYPE 12345
 
 struct PeerContext
@@ -75,6 +80,8 @@
 static int connected;
 
 static unsigned long long total_bytes;
+static unsigned long long current_quota_p1;
+static unsigned long long current_quota_p2;
 
 static struct GNUNET_TIME_Absolute start_time;
 
@@ -312,7 +319,33 @@
   return ret;
 }
 
+static void measure ()
+{
+#if VERBOSE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Both peers are connected, starting measurement...\n");
+#endif
+         GNUNET_TRANSPORT_set_quota (p1.th,
+                         &p2.id,
+                         GNUNET_BANDWIDTH_value_init (current_quota_p1 ),
+                         GNUNET_BANDWIDTH_value_init (current_quota_p1  ),
+                         GNUNET_TIME_UNIT_FOREVER_REL,
+                         NULL, NULL);
+         GNUNET_TRANSPORT_set_quota (p2.th,
+                         &p1.id,
+                         GNUNET_BANDWIDTH_value_init (current_quota_p2),
+                         GNUNET_BANDWIDTH_value_init (current_quota_p2),
+                         GNUNET_TIME_UNIT_FOREVER_REL,
+                         NULL, NULL);
+      GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
+                                              &p1.id,
+                                              get_size (0), 0, TIMEOUT,
+                                              &notify_ready,
+                                              NULL);
+      start_time = GNUNET_TIME_absolute_get ();
 
+}
+
 static void
 notify_connect (void *cls,
                 const struct GNUNET_PeerIdentity *peer,
@@ -323,38 +356,18 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
 #endif
-
   if (cls == &p1)
     {
-      GNUNET_TRANSPORT_set_quota (p1.th,
-                                 &p2.id,
-                                 GNUNET_BANDWIDTH_value_init (1024 * 10 ),
-                                 GNUNET_BANDWIDTH_value_init (1024 * 10 ),
-                                 GNUNET_TIME_UNIT_FOREVER_REL,
-                                 NULL, NULL);
-      start_time = GNUNET_TIME_absolute_get ();
       connected++;
     }
   else
     {
-      GNUNET_TRANSPORT_set_quota (p2.th,
-                                 &p1.id,
-                                 GNUNET_BANDWIDTH_value_init (1024 * 10 ),
-                                 GNUNET_BANDWIDTH_value_init (1024 * 10 ),
-                                 GNUNET_TIME_UNIT_FOREVER_REL,
-                                 NULL, NULL);
       connected++;
     }
-
   if (connected == 2)
     {
-      GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
-                                              &p1.id,
-                                              get_size (0), 0, TIMEOUT,
-                                              &notify_ready,
-                                              NULL);
+         measure();
     }
-
 }
 
 
@@ -400,10 +413,7 @@
   struct PeerContext *me = cls;
 
   GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
-#if VERBOSE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Exchanging HELLO with peer (%p)!\n", cls);
-#endif
+
   GNUNET_assert (ok >= 3);
   OKPP;
   GNUNET_assert (message != NULL);
@@ -412,7 +422,7 @@
                                       message, &me->id));
   /* both HELLOs exchanged, get ready to test transmission! */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Finished exchanging HELLOs, now waiting for transmission!\n");
+              "Finished exchanging HELLOs, now waiting for peers to 
connect!\n");
 }
 
 
@@ -423,22 +433,12 @@
   struct PeerContext *me = cls;
 
   GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
-#if VERBOSE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Exchanging HELLO with peer (%p)!\n", cls);
-#endif
   GNUNET_assert (ok >= 2);
   OKPP;
   GNUNET_assert (message != NULL);
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
                                       message, &me->id));
-
-#if VERBOSE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received HELLO size %d\n",
-             GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
-#endif
   GNUNET_TRANSPORT_offer_hello (p2.th, message);
   GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
 }
@@ -458,6 +458,9 @@
                                           &end_badly,
                                           NULL);
 
+  /* Setting initial quota for both peers */
+  current_quota_p1 = 1024 * 1024 * 1024;
+  current_quota_p2 = 1024 * 1024 * 1024;
 
   setup_peer (&p1, "test_quota_compliance_peer1.conf");
   setup_peer (&p2, "test_quota_compliance_peer2.conf");




reply via email to

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