gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r23332 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r23332 - gnunet/src/mesh
Date: Tue, 21 Aug 2012 09:36:47 +0200

Author: bartpolot
Date: 2012-08-21 09:36:47 +0200 (Tue, 21 Aug 2012)
New Revision: 23332

Modified:
   gnunet/src/mesh/mesh_api.c
Log:
- clients sends ACK only on threshold, ~1.7x speedup on loopback

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2012-08-21 06:01:06 UTC (rev 23331)
+++ gnunet/src/mesh/mesh_api.c  2012-08-21 07:36:47 UTC (rev 23332)
@@ -41,6 +41,7 @@
 
 #define LOG(kind,...) GNUNET_log_from (kind, "mesh-api",__VA_ARGS__)
 
+#define DEBUG_ACK GNUNET_YES
 
 
/******************************************************************************/
 /************************      DATA STRUCTURES     
****************************/
@@ -205,6 +206,11 @@
    * Task for trying to reconnect.
    */
   GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
+
+#if DEBUG_ACK
+  unsigned int acks_sent;
+  unsigned int acks_recv;
+#endif
 };
 
 
@@ -331,6 +337,11 @@
      * Last pid received from the service.
      */
   uint32_t last_recv_pid;
+
+  /**
+   * Which ACK value have we last sent to the service?
+   */
+  uint32_t max_recv_pid;
 };
 
 
@@ -695,15 +706,29 @@
 send_ack (struct GNUNET_MESH_Handle *h, struct GNUNET_MESH_Tunnel *t)
 {
   struct GNUNET_MESH_LocalAck msg;
+  uint32_t delta;
 
+  delta = t->max_recv_pid - t->last_recv_pid;
+  if (0 && delta > ACK_THRESHOLD)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Not sending ACK on tunnel %X: ACK: %u, PID: %u, buffer %u\n",
+         t->tid, t->max_recv_pid, t->last_recv_pid, delta);
+    return;
+  }
+  t->max_recv_pid = t->last_recv_pid + INITIAL_WINDOW_SIZE;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Sending ACK on tunnel %X: %u\n",
-       t->tid, t->last_recv_pid + INITIAL_WINDOW_SIZE);
+       t->tid, t->max_recv_pid);
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK);
   msg.header.size = htons (sizeof (msg));
   msg.tunnel_id = htonl (t->tid);
-  msg.max_pid = htonl (t->last_recv_pid + INITIAL_WINDOW_SIZE);
+  msg.max_pid = htonl (t->max_recv_pid);
 
+#if DEBUG_ACK
+  t->mesh->acks_sent++;
+#endif
+
   send_packet (h, &msg.header, t);
   return;
 }
@@ -1129,7 +1154,7 @@
     return GNUNET_YES;
   }
     if (GNUNET_YES ==
-        GMC_is_pid_bigger(pid, t->last_recv_pid + INITIAL_WINDOW_SIZE))
+        GMC_is_pid_bigger(pid, t->max_recv_pid))
   {
     GNUNET_break (0);
     LOG (GNUNET_ERROR_TYPE_WARNING, "  unauthorized message!\n");
@@ -1182,6 +1207,7 @@
   uint32_t ack;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Got an ACK!\n");
+  h->acks_recv++;
   msg = (struct GNUNET_MESH_LocalAck *) message;
 
   t = retrieve_tunnel (h, ntohl (msg->tunnel_id));
@@ -1565,6 +1591,11 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "MESH DISCONNECT\n");
 
+#if DEBUG_ACK
+  LOG (GNUNET_ERROR_TYPE_INFO, "Sent %d ACKs\n", handle->acks_sent);
+  LOG (GNUNET_ERROR_TYPE_INFO, "Recv %d ACKs\n\n", handle->acks_recv);
+#endif
+
   t = handle->tunnels_head;
   while (NULL != t)
   {




reply via email to

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