gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24336 - gnunet/src/transport
Date: Tue, 16 Oct 2012 13:20:27 +0200

Author: wachs
Date: 2012-10-16 13:20:27 +0200 (Tue, 16 Oct 2012)
New Revision: 24336

Modified:
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_neighbours.h
   gnunet/src/transport/plugin_transport_http_client.c
   gnunet/src/transport/plugin_transport_http_server.c
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/plugin_transport_udp.c
   gnunet/src/transport/plugin_transport_unix.c
   gnunet/src/transport/plugin_transport_wlan.c
Log:
overhead reporting

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2012-10-16 
08:20:22 UTC (rev 24335)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2012-10-16 
11:20:27 UTC (rev 24336)
@@ -562,11 +562,14 @@
  * @param success GNUNET_OK on success, GNUNET_NO on failure, GNUNET_SYSERR if 
we're not connected
  */
 static void
-handle_send_transmit_continuation (void *cls, int success)
+handle_send_transmit_continuation (void *cls, int success,
+                                   size_t bytes_payload, size_t bytes_on_wire)
 {
   struct SendTransmitContinuationContext *stcc = cls;
   struct SendOkMessage send_ok_msg;
 
+  //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Payload: %u, On wire %u \n", 
bytes_payload, bytes_on_wire);
+
   send_ok_msg.header.size = htons (sizeof (send_ok_msg));
   send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
   send_ok_msg.success = htonl (success);

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2012-10-16 
08:20:22 UTC (rev 24335)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2012-10-16 
11:20:27 UTC (rev 24336)
@@ -862,7 +862,7 @@
   {
     GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
     if (NULL != mq->cont)
-      mq->cont (mq->cont_cls, GNUNET_SYSERR);
+      mq->cont (mq->cont_cls, GNUNET_SYSERR, mq->message_buf_size, 0);
     GNUNET_free (mq);
   }
   /* It is too late to send other peer disconnect notifications, but at
@@ -955,7 +955,7 @@
                            timeout,
                            cont, cont_cls)))) &&
        (NULL != cont))
-    cont (cont_cls, &n->id, GNUNET_SYSERR);
+    cont (cont_cls, &n->id, GNUNET_SYSERR, msgbuf_size, 0);
   GNUNET_break (NULL != papi);
 }
 
@@ -983,7 +983,7 @@
  */
 static void
 send_disconnect_cont (void *cls, const struct GNUNET_PeerIdentity *target,
-                      int result)
+                      int result, size_t payload, size_t physical)
 {
   struct NeighbourMapEntry *n;
 
@@ -1130,7 +1130,7 @@
 static void
 transmit_send_continuation (void *cls,
                             const struct GNUNET_PeerIdentity *receiver,
-                            int success)
+                            int success, size_t size_payload, size_t physical)
 {
   struct MessageQueue *mq = cls;
   struct NeighbourMapEntry *n;
@@ -1150,6 +1150,7 @@
     n->task = GNUNET_SCHEDULER_add_now (&master_task, n);    
   }
   GNUNET_assert (bytes_in_send_queue >= mq->message_buf_size);
+  GNUNET_break (size_payload == mq->message_buf_size);
   bytes_in_send_queue -= mq->message_buf_size;
   GNUNET_STATISTICS_set (GST_stats,
                         gettext_noop
@@ -1171,7 +1172,7 @@
               ntohs (((struct GNUNET_MessageHeader *) mq->message_buf)->type),
               (success == GNUNET_OK) ? "success" : "FAILURE");
   if (NULL != mq->cont)
-    mq->cont (mq->cont_cls, success);
+    mq->cont (mq->cont_cls, success, size_payload, physical);
   GNUNET_free (mq);
 }
 
@@ -1224,7 +1225,7 @@
                              1, GNUNET_NO);
     GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
     n->is_active = mq;
-    transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);     /* timeout */
+    transmit_send_continuation (mq, &n->id, GNUNET_SYSERR, 
mq->message_buf_size, 0);     /* timeout */
   }
   if (NULL == mq)
     return;                     /* no more messages */
@@ -1477,14 +1478,14 @@
   {
     GNUNET_break (0);
     if (NULL != cont)
-      cont (cont_cls, GNUNET_SYSERR);
+      cont (cont_cls, GNUNET_SYSERR, msg_size, 0);
     return;
   }
   if (GNUNET_YES != test_connected (n))
   {
     GNUNET_break (0);
     if (NULL != cont)
-      cont (cont_cls, GNUNET_SYSERR);
+      cont (cont_cls, GNUNET_SYSERR, msg_size, 0);
     return;
   }
   bytes_in_send_queue += msg_size;

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h  2012-10-16 
08:20:22 UTC (rev 24335)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h  2012-10-16 
11:20:27 UTC (rev 24336)
@@ -84,7 +84,9 @@
  * @param cls closure
  * @param success GNUNET_OK on success, GNUNET_NO on failure, GNUNET_SYSERR if 
we're not connected
  */
-typedef void (*GST_NeighbourSendContinuation) (void *cls, int success);
+typedef void (*GST_NeighbourSendContinuation) (void *cls, int success,
+                                               size_t bytes_payload,
+                                               size_t bytes_on_wire);
 
 
 /**

Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2012-10-16 08:20:22 UTC 
(rev 24335)
+++ gnunet/src/transport/plugin_transport_http_client.c 2012-10-16 11:20:27 UTC 
(rev 24336)
@@ -85,6 +85,12 @@
   size_t size;
 
   /**
+   * HTTP overhead required to send this message
+   * FIXME: to implement
+   */
+  size_t overhead;
+
+  /**
    * Continuation function to call once the transmission buffer
    * has again space available.  NULL if there is no
    * continuation to call.
@@ -546,7 +552,8 @@
     next = pos->next;
     GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, pos);
     if (pos->transmit_cont != NULL)
-      pos->transmit_cont (pos->transmit_cont_cls, &s->target, GNUNET_SYSERR);
+      pos->transmit_cont (pos->transmit_cont_cls, &s->target, GNUNET_SYSERR,
+                          pos->size, pos->pos + pos->overhead);
     GNUNET_free (pos);
   }
 
@@ -631,7 +638,8 @@
   {
     t = msg->next;
     if (NULL != msg->transmit_cont)
-      msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
+      msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR,
+                          msg->size, msg->pos + msg->overhead);
     GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
     GNUNET_free (msg);
     msg = t;
@@ -784,7 +792,8 @@
     /* Calling transmit continuation  */
     GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
     if (NULL != msg->transmit_cont)
-      msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK);
+      msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK,
+                          msg->size, msg->size + msg->overhead);
     GNUNET_free (msg);
   }
 

Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2012-10-16 08:20:22 UTC 
(rev 24335)
+++ gnunet/src/transport/plugin_transport_http_server.c 2012-10-16 11:20:27 UTC 
(rev 24336)
@@ -398,6 +398,11 @@
   size_t size;
 
   /**
+   * HTTP/S specific overhead
+   */
+  size_t overhead;
+
+  /**
    * Continuation function to call once the transmission buffer
    * has again space available.  NULL if there is no
    * continuation to call.
@@ -680,7 +685,8 @@
     GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
     if (msg->transmit_cont != NULL)
     {
-      msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
+      msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR,
+                          msg->size, msg->pos + msg->overhead);
     }
     GNUNET_free (msg);
     msg = tmp;
@@ -1203,7 +1209,8 @@
     {
       GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
       if (NULL != msg->transmit_cont)
-        msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK);
+        msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK,
+                            msg->size, msg->size + msg->overhead);
       GNUNET_free (msg);
     }
   }

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2012-10-16 08:20:22 UTC (rev 
24335)
+++ gnunet/src/transport/plugin_transport_tcp.c 2012-10-16 11:20:27 UTC (rev 
24336)
@@ -849,7 +849,7 @@
     {
       GNUNET_CONTAINER_DLL_remove (hd, tl, pos);
       if (pos->transmit_cont != NULL)
-        pos->transmit_cont (pos->transmit_cont_cls, &pid, GNUNET_SYSERR);
+        pos->transmit_cont (pos->transmit_cont_cls, &pid, GNUNET_SYSERR, 
pos->message_size, 0);
       GNUNET_free (pos);
     }
     GNUNET_STATISTICS_update (plugin->env->stats,
@@ -895,7 +895,7 @@
   {
     GNUNET_CONTAINER_DLL_remove (hd, tl, pos);
     if (pos->transmit_cont != NULL)
-      pos->transmit_cont (pos->transmit_cont_cls, &pid, GNUNET_OK);
+      pos->transmit_cont (pos->transmit_cont_cls, &pid, GNUNET_OK, 
pos->message_size, pos->message_size); /* FIXME: include TCP overhead */
     GNUNET_free (pos);
   }
   GNUNET_assert (hd == NULL);
@@ -999,7 +999,7 @@
                                  session->pending_messages_tail, pm);
     if (NULL != pm->transmit_cont)
       pm->transmit_cont (pm->transmit_cont_cls, &session->target,
-                         GNUNET_SYSERR);
+                         GNUNET_SYSERR, pm->message_size, 0);
     GNUNET_free (pm);
   }
   if (session->receive_delay_task != GNUNET_SCHEDULER_NO_TASK)
@@ -1159,7 +1159,7 @@
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Invalid session %p\n", session);
     if (NULL != cont)
-      cont (cont_cls, &session->target, GNUNET_SYSERR);
+      cont (cont_cls, &session->target, GNUNET_SYSERR, pm->message_size, 0);
     GNUNET_break (0);
     GNUNET_free (pm);
     return GNUNET_SYSERR; /* session does not exist here */

Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2012-10-16 08:20:22 UTC (rev 
24335)
+++ gnunet/src/transport/plugin_transport_udp.c 2012-10-16 11:20:27 UTC (rev 
24336)
@@ -273,6 +273,11 @@
    * Payload size of original unfragmented message
    */
   size_t payload_size;
+
+  /**
+   * Bytes used to send all fragments on wire including UDP overhead
+   */
+  size_t on_wire_size;
 };
 
 
@@ -688,7 +693,12 @@
   if (NULL != udpw->cont)
   {
     /* FIXME: add bytes used on wire here */
-    udpw->cont (udpw->cont_cls, &udpw->session->target, result);
+    /* Calls transport continuation if message was not fragmented,
+     * GNUNET_FRAGMENT if just an fragment was sent
+     */
+
+    /* Call continuation for fragmented message */
+    udpw->cont (udpw->cont_cls, &udpw->session->target, result, 
udpw->payload_size, udpw->msg_size);
   }
 
 }
@@ -837,7 +847,8 @@
   {
     if (NULL != s->frag_ctx->cont)
     {
-      s->frag_ctx->cont (s->frag_ctx->cont_cls, &s->target, GNUNET_SYSERR);
+      s->frag_ctx->cont (s->frag_ctx->cont_cls, &s->target, GNUNET_SYSERR,
+                         s->frag_ctx->payload_size, s->frag_ctx->on_wire_size);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
           "Calling continuation for fragemented message to `%s' with result 
SYSERR\n",
           GNUNET_i2s (&s->target));
@@ -1186,10 +1197,9 @@
 static void
 send_next_fragment (void *cls,
                    const struct GNUNET_PeerIdentity *target,
-                   int result)
+                   int result, size_t payload, size_t physical)
 {
   struct UDP_MessageWrapper *udpw = cls;
-
   GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag);  
 }
 
@@ -1223,6 +1233,7 @@
   udpw->timeout = frag_ctx->timeout;
   udpw->frag_ctx = frag_ctx;
   memcpy (udpw->msg_buf, msg, msg_len);
+  frag_ctx->on_wire_size += msg_len;
   enqueue (plugin, udpw);
   schedule_select (plugin);
 }
@@ -1337,6 +1348,7 @@
     frag_ctx->cont_cls = cont_cls;
     frag_ctx->timeout = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), 
to);
     frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without 
UDP overhead */
+    frag_ctx->on_wire_size = 0;
     frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats,
               UDP_MTU,
               &plugin->tracker,
@@ -1344,7 +1356,6 @@
               &udp->header,
               &enqueue_fragment,
               frag_ctx);
-
     s->frag_ctx = frag_ctx;
   }
   schedule_select (plugin);
@@ -1714,11 +1725,12 @@
         "UDP processes %u-byte acknowledgement from `%s' at `%s'\n",
         (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender),
         GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
+    /* Expect more ACKs to arrive */
     return;
   }
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "FULL MESSAGE ACKed\n",
+       "Message full ACK'ed\n",
        (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender),
        GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
   s->last_expected_delay = GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag);
@@ -1759,7 +1771,9 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Calling continuation for fragmented message to `%s' with result %s\n",
         GNUNET_i2s (&s->target), "OK");
-    s->frag_ctx->cont (s->frag_ctx->cont_cls, &udp_ack->sender, GNUNET_OK);
+    /* FIXME add overhead bytes here */
+    s->frag_ctx->cont (s->frag_ctx->cont_cls, &udp_ack->sender, GNUNET_OK,
+                       s->frag_ctx->payload_size, s->frag_ctx->on_wire_size);
   }
 
   GNUNET_free (s->frag_ctx);

Modified: gnunet/src/transport/plugin_transport_unix.c
===================================================================
--- gnunet/src/transport/plugin_transport_unix.c        2012-10-16 08:20:22 UTC 
(rev 24335)
+++ gnunet/src/transport/plugin_transport_unix.c        2012-10-16 11:20:27 UTC 
(rev 24336)
@@ -377,7 +377,8 @@
       continue;
     GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
     if (NULL != msgw->cont)
-      msgw->cont (msgw->cont_cls,  &msgw->session->target, GNUNET_SYSERR);
+      msgw->cont (msgw->cont_cls,  &msgw->session->target, GNUNET_SYSERR,
+                  msgw->msgsize, 0);
     GNUNET_free (msgw->msg);
     GNUNET_free (msgw);
     removed = GNUNET_YES;    
@@ -442,7 +443,8 @@
   {
     GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
     if (msgw->cont != NULL)
-      msgw->cont (msgw->cont_cls,  &msgw->session->target, GNUNET_SYSERR);
+      msgw->cont (msgw->cont_cls,  &msgw->session->target, GNUNET_SYSERR,
+                  msgw->msgsize, 0);
     GNUNET_free (msgw->msg);
     GNUNET_free (msgw);
   }
@@ -508,7 +510,7 @@
     /* We do not have a send handle */
     GNUNET_break (0);
     if (cont != NULL)
-      cont (cont_cls, target, GNUNET_SYSERR);
+      cont (cont_cls, target, GNUNET_SYSERR, msgbuf_size, 0);
     return -1;
   }
   if ((addr == NULL) || (addrlen == 0))
@@ -516,7 +518,7 @@
     /* Can never send if we don't have an address */
     GNUNET_break (0);
     if (cont != NULL)
-      cont (cont_cls, target, GNUNET_SYSERR);
+      cont (cont_cls, target, GNUNET_SYSERR, msgbuf_size, 0);
     return -1;
   }
 
@@ -598,9 +600,9 @@
   if (cont != NULL)
   {
     if (sent == GNUNET_SYSERR)
-      cont (cont_cls, target, GNUNET_SYSERR);
+      cont (cont_cls, target, GNUNET_SYSERR, msgbuf_size, 0);
     if (sent > 0)
-      cont (cont_cls, target, GNUNET_OK);
+      cont (cont_cls, target, GNUNET_OK, msgbuf_size, msgbuf_size);
   }
 
   /* return number of bytes successfully sent */

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2012-10-16 08:20:22 UTC 
(rev 24335)
+++ gnunet/src/transport/plugin_transport_wlan.c        2012-10-16 11:20:27 UTC 
(rev 24336)
@@ -260,6 +260,16 @@
    */
   void *cont_cls;
 
+  /**
+   * Size of original message
+   */
+  size_t size_payload;
+
+  /**
+   * Number of bytes used to transmit message
+   */
+  size_t size_on_wire;
+
 };
 
 
@@ -745,6 +755,7 @@
                                 &radio_header->header,
                                 GNUNET_NO,
                                 &fragment_transmission_done, fm);
+    fm->size_on_wire += size;
     if (NULL != fm->sh)
       GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN 
message fragments sent"),
                                1, GNUNET_NO);
@@ -804,7 +815,7 @@
   fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   if (NULL != fm->cont)
   {
-    fm->cont (fm->cont_cls, &fm->target, GNUNET_SYSERR);
+    fm->cont (fm->cont_cls, &fm->target, GNUNET_SYSERR, fm->size_payload, 
fm->size_on_wire);
     fm->cont = NULL;
   }
   free_fragment_message (fm);
@@ -818,6 +829,7 @@
  * @param timeout how long can the message wait?
  * @param target peer that should receive the message
  * @param msg message to transmit
+ * @param bytes of payload
  * @param cont continuation to call once the message has
  *        been transmitted (or if the transport is ready
  *        for the next transmission call; or if the
@@ -829,6 +841,7 @@
                         struct GNUNET_TIME_Relative timeout,
                         const struct GNUNET_PeerIdentity *target,              
         
                         const struct GNUNET_MessageHeader *msg,
+                        size_t payload_size,
                         GNUNET_TRANSPORT_TransmitContinuation cont, void 
*cont_cls)
 
 {
@@ -839,6 +852,8 @@
   fm = GNUNET_malloc (sizeof (struct FragmentMessage));
   fm->macendpoint = endpoint;
   fm->target = *target;
+  fm->size_payload = payload_size;
+  fm->size_on_wire = 0;
   fm->timeout = GNUNET_TIME_relative_to_absolute (timeout);
   fm->cont = cont;
   fm->cont_cls = cont_cls;
@@ -1079,6 +1094,7 @@
                           to,
                           &session->target,
                           &wlanheader->header,
+                          msgbuf_size,
                           cont, cont_cls);
   return size;
 }
@@ -1177,7 +1193,7 @@
        mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute 
(MACENDPOINT_TIMEOUT);
        if (NULL != fm->cont)
        {
-         fm->cont (fm->cont_cls, &fm->target, GNUNET_OK);
+         fm->cont (fm->cont_cls, &fm->target, GNUNET_OK, fm->size_payload, 
fm->size_on_wire);
          fm->cont = NULL;
        }
         free_fragment_message (fm);




reply via email to

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