gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r13427 - in gnunet/src: topology transport


From: gnunet
Subject: [GNUnet-SVN] r13427 - in gnunet/src: topology transport
Date: Wed, 27 Oct 2010 12:04:42 +0200

Author: wachs
Date: 2010-10-27 12:04:42 +0200 (Wed, 27 Oct 2010)
New Revision: 13427

Modified:
   gnunet/src/topology/gnunet-daemon-topology.c
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/plugin_transport_http.c
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/plugin_transport_wlan.c
   gnunet/src/transport/test_quota_compliance.c
   gnunet/src/transport/test_transport_api_reliability.c
   gnunet/src/transport/transport_api.c
Log:
Refactoring gnunet time


Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c        2010-10-27 09:54:53 UTC 
(rev 13426)
+++ gnunet/src/topology/gnunet-daemon-topology.c        2010-10-27 10:04:42 UTC 
(rev 13427)
@@ -389,7 +389,7 @@
     return;
   if (GNUNET_OK != is_connection_allowed (pos))
     return;
-  if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).value > 0)
+  if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value > 0)
     return;
   if (GNUNET_YES == pos->is_friend)
     rem = GREYLIST_AFTER_ATTEMPT_FRIEND;
@@ -446,7 +446,7 @@
 
   pos->greylist_clean_task = GNUNET_SCHEDULER_NO_TASK;
   rem = GNUNET_TIME_absolute_get_remaining (pos->greylisted_until);
-  if (rem.value == 0)
+  if (rem.rel_value == 0)
     {
       attempt_connect (pos);
     }
@@ -586,7 +586,7 @@
   if (pos->hello == NULL)
     return GNUNET_YES;
   rst_time = GNUNET_TIME_absolute_get_remaining (pos->filter_expiration);
-  if (0 == rst_time.value)
+  if (0 == rst_time.rel_value)
     {
       /* time to discard... */
       GNUNET_CONTAINER_bloomfilter_free (pos->filter);
@@ -643,7 +643,7 @@
     return;   
   next_want = GNUNET_HELLO_size (fah.result->hello);
   delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed);
-  if (delay.value == 0)
+  if (delay.rel_value == 0)
     {
       /* now! */
       pl->hello_req = GNUNET_CORE_notify_transmit_ready (handle, 0,
@@ -733,7 +733,7 @@
   else
     {
       GNUNET_assert (GNUNET_NO == pos->is_connected);
-      pos->greylisted_until.value = 0; /* remove greylisting */
+      pos->greylisted_until.abs_value = 0; /* remove greylisting */
     }
   pos->is_connected = GNUNET_YES;
   pos->connect_attempts = 0; /* re-set back-off factor */
@@ -893,7 +893,7 @@
       dt = GNUNET_HELLO_equals (peer->hello,
                                hello,
                                GNUNET_TIME_absolute_get());
-      if (dt.value == GNUNET_TIME_UNIT_FOREVER_ABS.value)
+      if (dt.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
        return; /* nothing new here */
     }
 #if DEBUG_TOPOLOGY
@@ -961,7 +961,7 @@
            }
          if ( (! pos->is_connected) &&
               (! pos->is_friend) &&
-              (0 == GNUNET_TIME_absolute_get_remaining 
(pos->greylisted_until).value) )
+              (0 == GNUNET_TIME_absolute_get_remaining 
(pos->greylisted_until).rel_value) )
            free_peer (NULL, &pos->pid.hashPubKey, pos);
        }
       return;
@@ -981,7 +981,7 @@
 #endif 
       return;
     }
-  if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).value > 0)
+  if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value > 0)
     {
 #if DEBUG_TOPOLOGY
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-10-27 09:54:53 UTC 
(rev 13426)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-10-27 10:04:42 UTC 
(rev 13427)
@@ -1496,7 +1496,7 @@
       addresses = head->addresses;
       while (addresses != NULL)
         {
-          if ( (addresses->timeout.value < now.value) &&
+          if ( (addresses->timeout.abs_value < now.abs_value) &&
               (addresses->connected == GNUNET_YES) )
             {
 #if DEBUG_TRANSPORT
@@ -1528,7 +1528,7 @@
                        addresses->in_transmit,
                        addresses->validated,
                        addresses->connect_attempts,
-                       (unsigned long long) addresses->timeout.value,
+                       (unsigned long long) addresses->timeout.abs_value,
                        (unsigned int) addresses->distance);
 #endif
           if ( ( (best_address == NULL) ||
@@ -1536,7 +1536,7 @@
                 (best_address->connected == GNUNET_NO) ) &&
               (addresses->in_transmit == GNUNET_NO) &&
               ( (best_address == NULL) ||
-                (addresses->latency.value < best_address->latency.value)) )
+                (addresses->latency.rel_value < 
best_address->latency.rel_value)) )
            best_address = addresses;
          /* FIXME: also give lower-latency addresses that are not
             connected a chance some times... */
@@ -1554,7 +1554,7 @@
                       best_address->addr,
                       best_address->addrlen)
                  : "<inbound>",
-                  best_address->latency.value);
+                  best_address->latency.abs_value);
 #endif
     }
   else
@@ -1627,7 +1627,7 @@
                                1,
                                GNUNET_NO);
       timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout);
-      if (timeout.value == 0)
+      if (timeout.rel_value == 0)
        {
 #if DEBUG_TRANSPORT
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1667,7 +1667,7 @@
                  "No validated destination address available to transmit 
message of size %u to peer `%4s', will wait %llums to find an address.\n",
                  mq->message_buf_size,
                  GNUNET_i2s (&mq->neighbour_id),
-                 timeout.value);
+                 timeout.abs_value);
 #endif
       /* FIXME: might want to trigger peerinfo lookup here
         (unless that's already pending...) */
@@ -1928,13 +1928,13 @@
   plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK;
   now = GNUNET_TIME_absolute_get ();
   min_remaining = GNUNET_TIME_UNIT_FOREVER_REL;
-  expired = (GNUNET_TIME_absolute_get_duration (last_update).value > 
(HELLO_ADDRESS_EXPIRATION.value / 4));
+  expired = (GNUNET_TIME_absolute_get_duration (last_update).rel_value > 
(HELLO_ADDRESS_EXPIRATION.rel_value / 4));
   prev = NULL;
   pos = plugin->addresses;
   while (pos != NULL)
     {
       next = pos->next;
-      if (pos->expires.value < now.value)
+      if (pos->expires.abs_value < now.abs_value)
         {
           expired = GNUNET_YES;
           if (prev == NULL)
@@ -1946,7 +1946,7 @@
       else
         {
           remaining = GNUNET_TIME_absolute_get_remaining (pos->expires);
-          if (remaining.value < min_remaining.value)
+          if (remaining.rel_value < min_remaining.rel_value)
             min_remaining = remaining;
           prev = pos;
         }
@@ -2191,7 +2191,7 @@
     {
       if ((addrlen == al->addrlen) && (0 == memcmp (addr, &al[1], addrlen)))
         {
-          if (al->expires.value < abex.value)
+          if (al->expires.abs_value < abex.abs_value)
             al->expires = abex;
           return;
         }
@@ -2631,7 +2631,7 @@
                  a2s (tname, addr, addrlen),
                  tname,
                  GNUNET_i2s (&n->id),
-                 expiration.value);
+                 expiration.abs_value);
 #endif
       fal = add_peer_address (n, tname, NULL, addr, addrlen);
       if (fal == NULL)
@@ -3364,7 +3364,7 @@
   if (fal->revalidate_task != GNUNET_SCHEDULER_NO_TASK)
     return;
   delay = GNUNET_TIME_absolute_get_remaining (fal->expires);
-  delay.value /= 2; /* do before expiration */
+  delay.rel_value /= 2; /* do before expiration */
   delay = GNUNET_TIME_relative_min (delay,
                                    LATENCY_EVALUATION_MAX_DELAY);
   if (GNUNET_YES != fal->estimated)
@@ -3383,7 +3383,7 @@
   delay = GNUNET_TIME_relative_max (delay,
                                    GNUNET_TIME_UNIT_SECONDS);
   /* randomize a bit (to avoid doing all at the same time) */
-  delay.value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
+  delay.rel_value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 
1000);
   fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(sched,
                                                      delay,
                                                      &send_periodic_ping,
@@ -3627,7 +3627,7 @@
       GNUNET_break_op (0);
       return GNUNET_NO;
     }
-  if (GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh 
(pong->expiration)).value == 0)
+  if (GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh 
(pong->expiration)).rel_value == 0)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                  _("Received expired signature.  Check system time.\n"));
@@ -3672,10 +3672,10 @@
                                GNUNET_NO);
       fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time);
       schedule_next_ping (fal);
-      if (n->latency.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
+      if (n->latency.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
        n->latency = fal->latency;
       else
-       n->latency.value = (fal->latency.value + n->latency.value) / 2;
+       n->latency.rel_value = (fal->latency.rel_value + n->latency.rel_value) 
/ 2;
 
       n->distance = fal->distance;
       if (GNUNET_NO == n->received_pong)
@@ -4200,7 +4200,7 @@
     {
       if (GNUNET_HELLO_equals (hello,
                               chvc->hello,
-                              GNUNET_TIME_absolute_get ()).value > 0)
+                              GNUNET_TIME_absolute_get ()).abs_value > 0)
        {
 #if DEBUG_TRANSPORT_HELLO > 2
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4500,7 +4500,7 @@
       memcpy (&((char*)&pong[1])[slen],
              sender_address,
              sender_address_len);
-      if (GNUNET_TIME_absolute_get_remaining 
(session_header->pong_sig_expires).value < PONG_SIGNATURE_LIFETIME.value / 4)
+      if (GNUNET_TIME_absolute_get_remaining 
(session_header->pong_sig_expires).rel_value < 
PONG_SIGNATURE_LIFETIME.rel_value / 4)
        {
          /* create / update cached sig */
 #if DEBUG_TRANSPORT
@@ -4568,7 +4568,7 @@
       memcpy (&pong[1], plugin->short_name, slen);
       memcpy (&((char*)&pong[1])[slen], addr, alen);
       if ( (oal != NULL) &&
-          (GNUNET_TIME_absolute_get_remaining (oal->pong_sig_expires).value < 
PONG_SIGNATURE_LIFETIME.value / 4) )
+          (GNUNET_TIME_absolute_get_remaining 
(oal->pong_sig_expires).rel_value < PONG_SIGNATURE_LIFETIME.rel_value / 4) )
        {
          /* create / update cached sig */
 #if DEBUG_TRANSPORT
@@ -4786,16 +4786,16 @@
        }
     }
   ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0);
-  if (ret.value > 0)
+  if (ret.rel_value > 0)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Throttling read (%llu bytes excess at %u b/s), waiting 
%llums before reading more.\n",
                  (unsigned long long) 
n->in_tracker.consumption_since_last_update__,
                  (unsigned int) n->in_tracker.available_bytes_per_s__,
-                 (unsigned long long) ret.value);
+                 (unsigned long long) ret.rel_value);
       GNUNET_STATISTICS_update (stats,
                                gettext_noop ("# ms throttling suggested"),
-                               (int64_t) ret.value,
+                               (int64_t) ret.rel_value,
                                GNUNET_NO);
     }
   return ret;

Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2010-10-27 09:54:53 UTC 
(rev 13426)
+++ gnunet/src/transport/plugin_transport_http.c        2010-10-27 10:04:42 UTC 
(rev 13427)
@@ -882,10 +882,10 @@
   if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK)
        GNUNET_SCHEDULER_cancel (pc->plugin->env->sched, pc->reset_task);
 
-  if (delay.value > 0)
+  if (delay.rel_value > 0)
   {
 #if DEBUG_HTTP
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota 
management: delay next read for %llu ms \n", ps, delay.value);
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota 
management: delay next read for %llu ms \n", ps, delay.rel_value);
 #endif
        pc->reset_task = GNUNET_SCHEDULER_add_delayed (pc->plugin->env->sched, 
delay, &reset_inbound_quota_delay, pc);
   }
@@ -1182,7 +1182,7 @@
     /* Recieving data */
     if ((*upload_data_size > 0) && (ps->recv_active == GNUNET_YES))
     {
-      if (pc->delay.value == 0)
+      if (pc->delay.rel_value == 0)
       {
 #if DEBUG_HTTP
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: PUT with %u bytes 
forwarded to MST\n", ps, *upload_data_size);
@@ -1193,7 +1193,7 @@
       else
       {
 #if DEBUG_HTTP
-         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: no inbound 
bandwidth available! Next read was delayed for  %llu ms\n", ps, 
ps->peercontext->delay.value);
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: no inbound 
bandwidth available! Next read was delayed for  %llu ms\n", ps, 
ps->peercontext->delay.rel_value);
 #endif
       }
       return MHD_YES;
@@ -1264,7 +1264,7 @@
                                 &max));
   haveto = MHD_get_timeout (daemon_handle, &timeout);
   if (haveto == MHD_YES)
-    tv.value = (uint64_t) timeout;
+    tv.rel_value = (uint64_t) timeout;
   else
     tv = GNUNET_TIME_UNIT_SECONDS;
   GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
@@ -1588,10 +1588,10 @@
   if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK)
        GNUNET_SCHEDULER_cancel (pc->plugin->env->sched, pc->reset_task);
 
-  if (delay.value > 0)
+  if (delay.rel_value > 0)
   {
 #if DEBUG_HTTP
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota 
management: delay next read for %llu ms \n", ps, delay.value);
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota 
management: delay next read for %llu ms \n", ps, delay.abs_value);
 #endif
        pc->reset_task = GNUNET_SCHEDULER_add_delayed (pc->plugin->env->sched, 
delay, &reset_inbound_quota_delay, pc);
   }
@@ -1611,10 +1611,10 @@
 {
   struct Session * ps = ptr;
 
-  if (ps->peercontext->delay.value > 0)
+  if (ps->peercontext->delay.rel_value > 0)
   {
 #if DEBUG_HTTP
-         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: no inbound 
bandwidth available! Next read was delayed for  %llu ms\n", ps, 
ps->peercontext->delay.value);
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: no inbound 
bandwidth available! Next read was delayed for  %llu ms\n", ps, 
ps->peercontext->delay.rel_value);
 #endif
          return (0);
   }
@@ -1935,7 +1935,7 @@
         curl_easy_setopt(ps->recv_endpoint, CURLOPT_READDATA, ps);
         curl_easy_setopt(ps->recv_endpoint, CURLOPT_WRITEFUNCTION, 
curl_receive_cb);
         curl_easy_setopt(ps->recv_endpoint, CURLOPT_WRITEDATA, ps);
-        curl_easy_setopt(ps->recv_endpoint, CURLOPT_TIMEOUT, (long) 
timeout.value);
+        curl_easy_setopt(ps->recv_endpoint, CURLOPT_TIMEOUT, (long) 
timeout.rel_value);
         curl_easy_setopt(ps->recv_endpoint, CURLOPT_PRIVATE, ps);
         curl_easy_setopt(ps->recv_endpoint, CURLOPT_CONNECTTIMEOUT, 
HTTP_CONNECT_TIMEOUT);
         curl_easy_setopt(ps->recv_endpoint, CURLOPT_BUFFERSIZE, 
2*GNUNET_SERVER_MAX_MESSAGE_SIZE);
@@ -2034,7 +2034,7 @@
                curl_easy_setopt(ps->send_endpoint, CURLOPT_READDATA, ps);
                curl_easy_setopt(ps->send_endpoint, CURLOPT_WRITEFUNCTION, 
curl_receive_cb);
                curl_easy_setopt(ps->send_endpoint, CURLOPT_READDATA, ps);
-               curl_easy_setopt(ps->send_endpoint, CURLOPT_TIMEOUT, (long) 
timeout.value);
+               curl_easy_setopt(ps->send_endpoint, CURLOPT_TIMEOUT, (long) 
timeout.rel_value);
                curl_easy_setopt(ps->send_endpoint, CURLOPT_PRIVATE, ps);
                curl_easy_setopt(ps->send_endpoint, CURLOPT_CONNECTTIMEOUT, 
HTTP_CONNECT_TIMEOUT);
                curl_easy_setopt(ps->send_endpoint, CURLOPT_BUFFERSIZE, 2 * 
GNUNET_SERVER_MAX_MESSAGE_SIZE);
@@ -2982,7 +2982,7 @@
   GNUNET_assert ((port > 0) && (port <= 65535));
   plugin->port_inbound = port;
   gn_timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT;
-  unsigned int timeout = (gn_timeout.value) / 1000;
+  unsigned int timeout = (gn_timeout.rel_value) / 1000;
   if ((plugin->http_server_daemon_v6 == NULL) && (plugin->use_ipv6 == 
GNUNET_YES) && (port != 0))
   {
        struct sockaddr * tmp = (struct sockaddr *) plugin->bind6_address;

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-10-27 09:54:53 UTC (rev 
13426)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-10-27 10:04:42 UTC (rev 
13427)
@@ -697,7 +697,7 @@
       ret = 0;
       now = GNUNET_TIME_absolute_get ();
       while ( (NULL != (pos = session->pending_messages_head)) &&
-             (pos->timeout.value <= now.value) )
+             (pos->timeout.abs_value <= now.abs_value) )
        {
          GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
                                       session->pending_messages_tail,
@@ -930,9 +930,9 @@
   if ( (s1->expecting_welcome == GNUNET_YES) &&
        (s2->expecting_welcome == GNUNET_NO) )
     return s2;
-  if (s1->last_activity.value < s2->last_activity.value)
+  if (s1->last_activity.abs_value < s2->last_activity.abs_value)
     return s2;
-  if (s1->last_activity.value > s2->last_activity.value)
+  if (s1->last_activity.abs_value > s2->last_activity.abs_value)
     return s1;
   if ( (GNUNET_YES == s1->inbound) &&
        (GNUNET_NO  == s2->inbound) )
@@ -1806,7 +1806,7 @@
                                         NULL, 0,
                                         session,
                                         NULL, 0);
-  if (delay.value == 0)
+  if (delay.rel_value == 0)
     GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
   else
     session->receive_delay_task =
@@ -1860,7 +1860,7 @@
                                session,
                                (GNUNET_YES == session->inbound) ? NULL : 
session->connect_addr,
                                (GNUNET_YES == session->inbound) ? 0 : 
session->connect_alen);
-  if (delay.value == 0)
+  if (delay.rel_value == 0)
     GNUNET_SERVER_receive_done (client, GNUNET_OK);
   else
     session->receive_delay_task =

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2010-10-27 09:54:53 UTC 
(rev 13426)
+++ gnunet/src/transport/plugin_transport_wlan.c        2010-10-27 10:04:42 UTC 
(rev 13427)
@@ -565,7 +565,7 @@
   struct GNUNET_TIME_Relative timeout;
   struct Sessionqueue * nextsession = NULL;
 
-  timeout.value = FRAGMENT_TIMEOUT;
+  timeout.rel_value = FRAGMENT_TIMEOUT;
   nextsend = GNUNET_TIME_absolute_get_forever();
 
   queue = plugin->pending_Sessions;
@@ -596,7 +596,7 @@
          //save next session
          nextsession = queue->next;
          // test if message timed out
-         while (GNUNET_TIME_absolute_get_remaining(pm->timeout).value == 0){
+         while (GNUNET_TIME_absolute_get_remaining(pm->timeout).rel_value == 
0){
                  //remove message
                  //free the acks
                  free_acks (pm);
@@ -637,7 +637,7 @@
          nextsession = NULL;
 
          // test if retransmit is needed
-         if (GNUNET_TIME_absolute_get_duration(pm->last_ack).value < 
FRAGMENT_TIMEOUT) {
+         if (GNUNET_TIME_absolute_get_duration(pm->last_ack).rel_value < 
FRAGMENT_TIMEOUT) {
                  // get last offset for this message
                  copyoffset = pm->message_size /(WLAN_MTU - sizeof(struct 
FragmentationHeader));
                  // one more is the end
@@ -693,7 +693,7 @@
   if (pm->message_size > WLAN_MTU) {
        size += sizeof(struct FragmentationHeader);
        // check for retransmission
-       if (GNUNET_TIME_absolute_get_duration(pm->last_ack).value > 
FRAGMENT_TIMEOUT) {
+       if (GNUNET_TIME_absolute_get_duration(pm->last_ack).rel_value > 
FRAGMENT_TIMEOUT) {
                // TODO retransmit
                // be positive and try again later :-D
                pm->last_ack = GNUNET_TIME_absolute_get();

Modified: gnunet/src/transport/test_quota_compliance.c
===================================================================
--- gnunet/src/transport/test_quota_compliance.c        2010-10-27 09:54:53 UTC 
(rev 13426)
+++ gnunet/src/transport/test_quota_compliance.c        2010-10-27 10:04:42 UTC 
(rev 13427)
@@ -49,18 +49,20 @@
  */
 #define TOTAL_MSGS (10000 * 2)
 
-#define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 3)
-#define MEASUREMENT_MSG_SIZE 1024
+#define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 5)
+#define MEASUREMENT_MSG_SIZE 10000
 #define MEASUREMENT_MSG_SIZE_BIG 32768
-#define MEASUREMENT_MAX_QUOTA 1024*1024*1024
-#define MEASUREMENT_MIN_QUOTA 1024
-
+#define MEASUREMENT_MAX_QUOTA 50000
+/*#define MEASUREMENT_MAX_QUOTA 1000000*/
+#define MEASUREMENT_MIN_QUOTA 1000
+#define SEND_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 
5)
 /**
  * Testcase timeout
  */
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 200)
 
 
+
 #define MTYPE 11111
 
 struct PeerContext
@@ -73,6 +75,54 @@
 #endif
 };
 
+/**
+ * Handle for a transmission-ready request.
+ */
+struct GNUNET_TRANSPORT_TransmitHandle
+{
+
+  /**
+   * Neighbour for this handle, NULL for control-traffic.
+   */
+  struct NeighbourList *neighbour;
+
+  /**
+   * Function to call when notify_size bytes are available
+   * for transmission.
+   */
+  GNUNET_CONNECTION_TransmitReadyNotify notify;
+
+  /**
+   * Closure for notify.
+   */
+  void *notify_cls;
+
+  /**
+   * transmit_ready task Id.  The task is used to introduce the
+   * artificial delay that may be required to maintain the bandwidth
+   * limits.  Later, this will be the ID of the "transmit_timeout"
+   * task which is used to signal a timeout if the transmission could
+   * not be done in a timely fashion.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier notify_delay_task;
+
+  /**
+   * Timeout for this request.
+   */
+  struct GNUNET_TIME_Absolute timeout;
+
+  /**
+   * How many bytes is our notify callback waiting for?
+   */
+  size_t notify_size;
+
+  /**
+   * How important is this message?
+   */
+  unsigned int priority;
+
+};
+
 static struct PeerContext p1;
 
 static struct PeerContext p2;
@@ -177,7 +227,7 @@
 };
 
 static unsigned int
-get_size_new (unsigned int iter)
+get_size (unsigned int iter)
 {
   return MEASUREMENT_MSG_SIZE + sizeof (struct TestMessage);
 }
@@ -194,7 +244,7 @@
   const struct TestMessage *hdr;
 
   hdr = (const struct TestMessage*) message;
-  s = get_size_new (n);
+  s = get_size (n);
   if (MTYPE != ntohs (message->type))
     return;
 #if DEBUG_MEASUREMENT
@@ -234,7 +284,7 @@
          return 0;
 
   ret = 0;
-  s = get_size_new (n);
+  s = get_size (n);
   GNUNET_assert (size >= s);
   GNUNET_assert (buf != NULL);
   cbuf = buf;
@@ -255,14 +305,14 @@
        }
 #endif
       n++;
-      s = get_size_new (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);
   transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
                                            &p1.id,
-                                           s, 0, TIMEOUT,
+                                           s, 0, SEND_TIMEOUT,
                                            &notify_ready_new,
                                            NULL);
   total_bytes += s;
@@ -313,14 +363,14 @@
          GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
          transmit_handle = NULL;
   }
-  if (current_quota_p1 < total_bytes/(duration.value / 1000))
+  if ((total_bytes/(duration.rel_value / 1000)) > (current_quota_p1 + 
(current_quota_p1 / 10)))
   {
          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                          "\nQuota compliance failed: \n"\
-                         "Quota allowed: %10llu kb/s\n"\
-                         "Throughput   : %10llu kb/s\n", (current_quota_p1 / 
(1024)) , (total_bytes/(duration.value / 1000)/1024));
+                         "Quota allowed: %10llu kB/s\n"\
+                         "Throughput   : %10llu kB/s\n", (current_quota_p1 / 
(1024)) , (total_bytes/(duration.rel_value / 1000)/1024));
          ok = 1;
-         end();
+         //end();
          return;
   }
   else
@@ -328,14 +378,15 @@
 
          GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                          "\nQuota compliance ok: \n"\
-                         "Quota allowed: %10llu kb/s\n"\
-                         "Throughput   : %10llu kb/s\n", (current_quota_p1 / 
(1024)) , (total_bytes/(duration.value / 1000)/1024));
+                         "Quota allowed: %10llu kB/s\n"\
+                         "Throughput   : %10llu kB/s\n", (current_quota_p1 / 
(1024)) , (total_bytes/(duration.rel_value / 1000)/1024));
          ok = 0;
   }
-  if (current_quota_p1 < (MEASUREMENT_MIN_QUOTA))
+  if (current_quota_p1 < MEASUREMENT_MIN_QUOTA)
          end();
   else
-       measure (current_quota_p1/100, current_quota_p2/100);
+
+       measure (current_quota_p1- 1000, current_quota_p2- 1000);
 }
 
 static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
@@ -344,7 +395,7 @@
          current_quota_p2 = quota_p2;
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Starting transport level measurement: Duration: %u Quota: 
%u\n", MEASUREMENT_INTERVALL, current_quota_p1);
+              "Starting transport level measurement: Duration: %u Quota: 
%llu\n", MEASUREMENT_INTERVALL, current_quota_p1);
 #endif
                GNUNET_TRANSPORT_set_quota (p1.th,
                          &p2.id,
@@ -383,7 +434,7 @@
 
                transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
                                                                                
          &p1.id,
-                                                                               
          get_size_new (0), 0, TIMEOUT,
+                                                                               
          get_size (0), 0, SEND_TIMEOUT,
                                                                                
          &notify_ready_new,
                                                                                
          NULL);
 }

Modified: gnunet/src/transport/test_transport_api_reliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_reliability.c       2010-10-27 
09:54:53 UTC (rev 13426)
+++ gnunet/src/transport/test_transport_api_reliability.c       2010-10-27 
10:04:42 UTC (rev 13427)
@@ -127,7 +127,7 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transports disconnected, returning success!\n");
 #endif
-  delta = GNUNET_TIME_absolute_get_duration (start_time).value;
+  delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
   fprintf (stderr,
           "\nThroughput was %llu kb/s\n",
           total_bytes * 1000 / 1024 / delta);

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2010-10-27 09:54:53 UTC (rev 
13426)
+++ gnunet/src/transport/transport_api.c        2010-10-27 10:04:42 UTC (rev 
13427)
@@ -465,13 +465,13 @@
       duration = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker,
                                                     th->notify_size - sizeof 
(struct OutboundMessage));
       struct GNUNET_TIME_Absolute duration_abs = 
GNUNET_TIME_relative_to_absolute (duration);
-      if (th->timeout.value < duration_abs.value)
+      if (th->timeout.abs_value < duration_abs.abs_value)
        {
          /* signal timeout! */
 #if DEBUG_TRANSPORT
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                      "Would need %llu ms before bandwidth is available for 
delivery to `%4s', that is too long.  Signaling timeout.\n",
-                     duration.value,
+                     duration.abs_value,
                      GNUNET_i2s (&n->id));
 #endif
          if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
@@ -484,7 +484,7 @@
            GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
          continue;
        }
-      if (duration.value > 0)
+      if (duration.rel_value > 0)
        {
 #if DEBUG_TRANSPORT
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -492,7 +492,7 @@
                      (unsigned int) n->out_tracker.available_bytes_per_s__,
                      (unsigned int) th->notify_size - sizeof (struct 
OutboundMessage),
                      GNUNET_i2s (&n->id),
-                     duration.value);
+                     duration.abs_value);
 #endif
          retry_time = GNUNET_TIME_relative_min (retry_time,
                                                 duration);
@@ -608,7 +608,7 @@
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Message of %u bytes with timeout %llums constructed for 
`%4s'\n",
                  (unsigned int) mret,
-                 (unsigned long long) GNUNET_TIME_absolute_get_remaining 
(th->timeout).value,
+                 (unsigned long long) GNUNET_TIME_absolute_get_remaining 
(th->timeout).abs_value,
                  GNUNET_i2s (&n->id));
 #endif
       if (mret != 0)   
@@ -755,7 +755,7 @@
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Control transmit of %u bytes within %llums requested\n",
-              size, (unsigned long long) timeout.value);
+              size, (unsigned long long) timeout.abs_value);
 #endif
   th = GNUNET_malloc (sizeof (struct ControlMessage));
   th->h = h;
@@ -1235,14 +1235,14 @@
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Scheduling task to reconnect to transport service in %llu 
ms.\n",
-              h->reconnect_delay.value);
+              h->reconnect_delay.abs_value);
 #endif
   GNUNET_assert (h->client == NULL);
   GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
   h->reconnect_task
     = GNUNET_SCHEDULER_add_delayed (h->sched,
                                     h->reconnect_delay, &reconnect, h);
-  if (h->reconnect_delay.value == 0)
+  if (h->reconnect_delay.rel_value == 0)
     {
       h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS;
     }
@@ -1798,12 +1798,12 @@
       GNUNET_break (0);
       return NULL;
     }
-
+#if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Asking transport service for transmission of %u bytes to peer 
`%4s' within %llu ms.\n",
               size, GNUNET_i2s (target),
-             (unsigned long long) timeout.value);
-
+             (unsigned long long) timeout.abs_value);
+#endif
   n = neighbour_find (handle, target);
   if (n == NULL)
     {




reply via email to

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