gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r28866 - gnunet/src/mesh
Date: Mon, 26 Aug 2013 15:41:20 +0200

Author: bartpolot
Date: 2013-08-26 15:41:20 +0200 (Mon, 26 Aug 2013)
New Revision: 28866

Modified:
   gnunet/src/mesh/gnunet-service-mesh-enc.c
   gnunet/src/mesh/mesh_protocol_enc.h
Log:
- separate channel from connection ack counting

Modified: gnunet/src/mesh/gnunet-service-mesh-enc.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh-enc.c   2013-08-26 12:11:21 UTC (rev 
28865)
+++ gnunet/src/mesh/gnunet-service-mesh-enc.c   2013-08-26 13:41:20 UTC (rev 
28866)
@@ -1586,7 +1586,93 @@
 }
 
 
+
+
 /**
+ * Is this peer the first one on the connection?
+ *
+ * @param c Connection.
+ * @param fwd Is this about fwd traffic?
+ *
+ * @return GNUNET_YES if origin, GNUNET_NO if relay/terminal.
+ */
+static int
+connection_is_origin (struct MeshConnection *c, int fwd)
+{
+  if (!fwd && c->own_pos == c->path->length - 1)
+    return GNUNET_YES;
+  if (fwd && c->own_pos == 0)
+    return GNUNET_YES;
+  return GNUNET_NO;
+}
+
+
+/**
+ * Is this peer the last one on the connection?
+ *
+ * @param c Connection.
+ * @param fwd Is this about fwd traffic?
+ *            Note that the ROOT is the terminal for BCK traffic!
+ *
+ * @return GNUNET_YES if terminal, GNUNET_NO if relay/origin.
+ */
+static int
+connection_is_terminal (struct MeshConnection *c, int fwd)
+{
+  if (fwd && c->own_pos == c->path->length - 1)
+    return GNUNET_YES;
+  if (!fwd && c->own_pos == 0)
+    return GNUNET_YES;
+  return GNUNET_NO;
+}
+
+
+/**
+ * Get free buffer space towards the client on a specific channel.
+ *
+ * @param ch Channel.
+ * @param fwd Is query about FWD traffic?
+ *
+ * @return Free buffer space [0 - 64]
+ */
+static unsigned int
+channel_get_buffer (struct MeshChannel *ch, int fwd)
+{
+  struct MeshChannelReliability *rel;
+  
+  rel = fwd ? ch->dest_rel : ch->root_rel;
+
+  /* If rel is NULL it means that the end is not yet created,
+   * most probably is a loopback channel at the point of sending
+   * the ChannelCreate to itself.
+   */
+  if (NULL == rel)
+    return 64;
+
+  return (64 - rel->n_recv);
+}
+
+
+/**
+ * Get free buffer space in a connection.
+ *
+ * @param c Connection.
+ * @param fwd Is query about FWD traffic?
+ *
+ * @return Free buffer space [0 - max_msgs_queue/max_connections]
+ */
+static unsigned int
+connection_get_buffer (struct MeshConnection *c, int fwd)
+{
+  struct MeshFlowControl *fc;
+  
+  fc = fwd ? &c->fwd_fc : &c->bck_fc;
+  
+  return (fc->queue_max - fc->queue_n);
+}
+
+
+/**
  * Get the total buffer space for a tunnel.
  */
 static unsigned int
@@ -1596,13 +1682,42 @@
   struct MeshFlowControl *fc;
   unsigned int buffer;
 
-  for (buffer = 0, c = t->connection_head; NULL != c; c = c->next)
+  c = t->connection_head;
+  buffer = 0;
+
+  if (NULL == c)
   {
+    GNUNET_break (0);
+    return 0;
+  }
+
+  /* If terminal, return biggest channel buffer */
+  if (connection_is_terminal (c, fwd))
+  {
+    struct MeshChannel *ch;
+    unsigned int ch_buf;
+
+    if (NULL == t->channel_head)
+      return 64;
+
+    for (ch = t->channel_head; NULL != ch; ch = ch->next)
+    {
+      ch_buf = channel_get_buffer (ch, fwd);
+      if (ch_buf > buffer)
+        buffer = ch_buf;
+    }
+    return buffer;
+  }
+
+  /* If not terminal, return sum of connection buffers */
+  while (NULL != c)
+  {
     if (c->state != MESH_CONNECTION_READY)
       continue;
 
     fc = fwd ? &c->fwd_fc : &c->bck_fc;
     buffer += fc->last_ack_recv - fc->last_pid_sent;
+    c = c->next;
   }
 
   return buffer;
@@ -2352,45 +2467,6 @@
 
 
 /**
- * Is this peer the first one on the connection?
- *
- * @param c Connection.
- * @param fwd Is this about fwd traffic?
- *
- * @return GNUNET_YES if origin, GNUNET_NO if relay/terminal.
- */
-static int
-connection_is_origin (struct MeshConnection *c, int fwd)
-{
-  if (!fwd && c->own_pos == c->path->length - 1)
-    return GNUNET_YES;
-  if (fwd && c->own_pos == 0)
-    return GNUNET_YES;
-  return GNUNET_NO;
-}
-
-
-/**
- * Is this peer the last one on the connection?
- *
- * @param c Connection.
- * @param fwd Is this about fwd traffic?
- *            Note that the ROOT is the terminal for BCK traffic!
- *
- * @return GNUNET_YES if terminal, GNUNET_NO if relay/origin.
- */
-static int
-connection_is_terminal (struct MeshConnection *c, int fwd)
-{
-  if (fwd && c->own_pos == c->path->length - 1)
-    return GNUNET_YES;
-  if (!fwd && c->own_pos == 0)
-    return GNUNET_YES;
-  return GNUNET_NO;
-}
-
-
-/**
  * @brief Re-initiate traffic on this connection if necessary.
  *
  * Check if there is traffic queued towards this peer
@@ -3657,44 +3733,6 @@
 
 
 /**
- * Get free buffer space towards the client on a specific channel.
- *
- * @param ch Channel.
- * @param fwd Is query about FWD traffic?
- *
- * @return Free buffer space [0 - 64]
- */
-static unsigned int
-channel_get_buffer (struct MeshChannel *ch, int fwd)
-{
-  struct MeshChannelReliability *rel;
-
-  rel = fwd ? ch->dest_rel : ch->root_rel;
-
-  return (64 - rel->n_recv);
-}
-
-
-/**
- * Get free buffer space in a connection.
- *
- * @param c Connection.
- * @param fwd Is query about FWD traffic?
- *
- * @return Free buffer space [0 - max_msgs_queue/max_connections]
- */
-static unsigned int
-connection_get_buffer (struct MeshConnection *c, int fwd)
-{
-  struct MeshFlowControl *fc;
-
-  fc = fwd ? &c->fwd_fc : &c->bck_fc;
-
-  return (fc->queue_max - fc->queue_n);
-}
-
-
-/**
  * Send an ACK on the appropriate connection/channel, depending on
  * the direction and the position of the peer.
  *
@@ -3710,7 +3748,7 @@
   if (NULL == c || connection_is_terminal (c, fwd))
   {
     GNUNET_assert (NULL != ch);
-    buffer = channel_get_buffer (ch, fwd);
+    buffer = tunnel_get_buffer (ch->t, fwd);
   }
   else
   {
@@ -3752,8 +3790,8 @@
   struct MeshReliableMessage *next;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "  channel confirm %s:%X\n",
-              peer2s (ch->t->peer), ch->gid);
+              "  channel confirm %s %s:%X\n",
+              fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid);
   ch->state = MESH_CHANNEL_READY;
 
   rel = fwd ? ch->root_rel : ch->dest_rel;
@@ -3769,6 +3807,8 @@
       /* TODO return? */
     }
   }
+  if (GNUNET_NO == rel->client_ready)
+    send_local_ack (ch, fwd);
 }
 
 
@@ -5695,7 +5735,7 @@
   {
     GNUNET_STATISTICS_update (stats, "# TTL drops", 1, GNUNET_NO);
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n");
-    connection_send_ack (c, connection_get_buffer (c, fwd), fwd);
+    send_ack (c, NULL, fwd);
     return GNUNET_OK;
   }
   GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO);
@@ -5881,7 +5921,7 @@
               pid, fc->last_pid_recv);
   fc->last_pid_recv = pid;
   fwd = fc == &c->fwd_fc;
-  connection_send_ack (c, connection_get_buffer(c, fwd), fwd);
+  send_ack (c, NULL, fwd);
 
   return GNUNET_OK;
 }

Modified: gnunet/src/mesh/mesh_protocol_enc.h
===================================================================
--- gnunet/src/mesh/mesh_protocol_enc.h 2013-08-26 12:11:21 UTC (rev 28865)
+++ gnunet/src/mesh/mesh_protocol_enc.h 2013-08-26 13:41:20 UTC (rev 28866)
@@ -119,7 +119,7 @@
   /**
    * Initialization Vector for payload encryption.
    */
-  uint64_t iv;
+  uint64_t iv GNUNET_PACKED;
 
   /**
    * Number of hops to live.




reply via email to

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