- measure overhead
[oweals/gnunet.git] / src / transport / plugin_transport_udp.c
index f133dd74978e360d8e5b6ef35ef093ea6dcda319..b6b13eab2ec33bd110c658dd9d4fb2be94b7165f 100644 (file)
@@ -86,6 +86,16 @@ struct PrettyPrinterContext
 };
 
 
+enum UDP_MessageType
+{
+  UNDEFINED = 0,
+  MSG_FRAGMENTED = 1,
+  MSG_FRAGMENTED_COMPLETE = 2,
+  MSG_UNFRAGMENTED = 3,
+  MSG_ACK = 4,
+  MSG_BEACON = 5
+};
+
 struct Session
 {
   /**
@@ -93,7 +103,7 @@ struct Session
    */
   struct GNUNET_PeerIdentity target;
 
-  struct FragmentationContext * frag_ctx;
+  struct UDP_FragmentationContext * frag_ctx;
 
   /**
    * Address of the other peer
@@ -225,15 +235,33 @@ struct DefragContext
 
 
 /**
- * Closure for 'process_inbound_tokenized_messages'
+ * Context to send fragmented messages
  */
-struct FragmentationContext
+struct UDP_FragmentationContext
 {
-  struct FragmentationContext * next;
-  struct FragmentationContext * prev;
+  /**
+   * Next in linked list
+   */
+  struct UDP_FragmentationContext * next;
 
+  /**
+   * Previous in linked list
+   */
+  struct UDP_FragmentationContext * prev;
+
+  /**
+   * The plugin
+   */
   struct Plugin * plugin;
+
+  /**
+   * Handle for GNUNET_FRAGMENT context
+   */
   struct GNUNET_FRAGMENT_Context * frag;
+
+  /**
+   * The session this fragmentation context belongs to
+   */
   struct Session * session;
 
   /**
@@ -246,34 +274,87 @@ struct FragmentationContext
    */
   void *cont_cls;
 
+  /**
+   * Message timeout
+   */
   struct GNUNET_TIME_Absolute timeout;
 
-  size_t bytes_to_send;
+  /**
+   * 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;
+
+  unsigned int fragments_used;
+  struct GNUNET_TIME_Relative exp_delay;
 };
 
 
-struct UDPMessageWrapper
+struct UDP_MessageWrapper
 {
+  /**
+   * Session this message belongs to
+   */
   struct Session *session;
-  struct UDPMessageWrapper *prev;
-  struct UDPMessageWrapper *next;
-  char *udp;
 
   /**
-   * Function to call upon completion of the transmission.
+   * DLL of messages
+   * previous element
    */
-  GNUNET_TRANSPORT_TransmitContinuation cont;
+  struct UDP_MessageWrapper *prev;
 
   /**
-   * Closure for 'cont'.
+   * DLL of messages
+   * previous element
    */
-  void *cont_cls;
+  struct UDP_MessageWrapper *next;
 
-  struct FragmentationContext *frag_ctx;
+  /**
+   * Message type
+   * According to UDP_MessageType
+   */
+  int msg_type;
 
+  /**
+   * Message with size msg_size including UDP specific overhead
+   */
+  char *msg_buf;
+
+  /**
+   * Size of UDP message to send including UDP specific overhead
+   */
   size_t msg_size;
 
+  /**
+   * Payload size of original message
+   */
+  size_t payload_size;
+
+  /**
+   * Message timeout
+   */
   struct GNUNET_TIME_Absolute timeout;
+
+  /**
+   * Function to call upon completion of the transmission.
+   */
+  GNUNET_TRANSPORT_TransmitContinuation cont;
+
+  /**
+   * Closure for 'cont'.
+   */
+  void *cont_cls;
+
+  /**
+   * Fragmentation context
+   * frag_ctx == NULL if transport <= MTU
+   * frag_ctx != NULL if transport > MTU
+   */
+  struct UDP_FragmentationContext *frag_ctx;
 };
 
 
@@ -357,10 +438,12 @@ static void
 schedule_select (struct Plugin *plugin)
 {
   struct GNUNET_TIME_Relative min_delay;
-  struct UDPMessageWrapper *udpw;
+  struct UDP_MessageWrapper *udpw;
 
   if (NULL != plugin->sockv4)
   {
+    /* Find a message ready to send:
+     * Flow delay from other peer is expired or not set (0) */
     min_delay = GNUNET_TIME_UNIT_FOREVER_REL;
     for (udpw = plugin->ipv4_queue_head; NULL != udpw; udpw = udpw->next)
       min_delay = GNUNET_TIME_relative_min (min_delay,
@@ -368,6 +451,10 @@ schedule_select (struct Plugin *plugin)
     
     if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)
       GNUNET_SCHEDULER_cancel(plugin->select_task);
+
+    /* Schedule with:
+     * - write active set if message is ready
+     * - timeout minimum delay */
     plugin->select_task =
       GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
                                   (0 == min_delay.rel_value) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay,
@@ -622,17 +709,181 @@ udp_plugin_address_pretty_printer (void *cls, const char *type,
 
 
 static void
-call_continuation (struct UDPMessageWrapper *udpw, int result)
+call_continuation (struct UDP_MessageWrapper *udpw, int result)
 {
+  size_t overhead;
+  struct UDP_MessageWrapper dummy;
+
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "Calling continuation for %u byte message to `%s' with result %s\n",
-      udpw->msg_size, GNUNET_i2s (&udpw->session->target),
+      udpw->payload_size, GNUNET_i2s (&udpw->session->target),
       (GNUNET_OK == result) ? "OK" : "SYSERR");
-  if (NULL != udpw->cont)
-  {
-    udpw->cont (udpw->cont_cls, &udpw->session->target,result);
-  }
 
+  if ((udpw->msg_size - udpw->payload_size) >= 0)
+    overhead = udpw->msg_size - udpw->payload_size;
+  else
+    overhead = udpw->msg_size;
+
+  switch (result) {
+    case GNUNET_OK:
+      switch (udpw->msg_type) {
+        case MSG_UNFRAGMENTED:
+          if (NULL != udpw->cont)
+          {
+            /* Transport continuation */
+            udpw->cont (udpw->cont_cls, &udpw->session->target, result,
+                      udpw->payload_size, overhead);
+          }
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, unfragmented msgs, messages, sent, success",
+                                    1, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, unfragmented msgs, bytes payload, sent, success",
+                                    udpw->payload_size, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, unfragmented msgs, bytes overhead, sent, success",
+                                    overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, total, bytes overhead, sent",
+                                    overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, total, bytes payload, sent",
+                                    udpw->payload_size, GNUNET_NO);
+          break;
+        case MSG_FRAGMENTED_COMPLETE:
+          GNUNET_assert (NULL != udpw->frag_ctx);
+          if (udpw->frag_ctx->cont != NULL)
+            udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls, &udpw->session->target, GNUNET_OK,
+                               udpw->frag_ctx->payload_size, udpw->frag_ctx->on_wire_size);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, messages, sent, success",
+                                    1, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, bytes payload, sent, success",
+                                    udpw->payload_size, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, bytes overhead, sent, success",
+                                    overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, total, bytes overhead, sent",
+                                    overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, total, bytes payload, sent",
+                                    udpw->payload_size, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, messages, pending",
+                                    -1, GNUNET_NO);
+          break;
+        case MSG_FRAGMENTED:
+          /* Fragmented message: enqueue next fragment */
+          if (NULL != udpw->cont)
+            udpw->cont (udpw->cont_cls, &udpw->session->target, result,
+                      udpw->payload_size, udpw->msg_size);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, fragments, sent, success",
+                                    1, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, fragments bytes, sent, success",
+                                    udpw->msg_size, GNUNET_NO);
+          break;
+        case MSG_ACK:
+          /* No continuation */
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, ACK msgs, messages, sent, success",
+                                    1, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, ACK msgs, bytes overhead, sent, success",
+                                    overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, total, bytes overhead, sent",
+                                    overhead, GNUNET_NO);
+          break;
+        case MSG_BEACON:
+          GNUNET_break (0);
+          break;
+        default:
+          LOG (GNUNET_ERROR_TYPE_ERROR,
+              "ERROR: %u\n", udpw->msg_type);
+          GNUNET_break (0);
+          break;
+      }
+      break;
+    case GNUNET_SYSERR:
+      switch (udpw->msg_type) {
+        case MSG_UNFRAGMENTED:
+          /* Unfragmented message: failed to send */
+          if (NULL != udpw->cont)
+            udpw->cont (udpw->cont_cls, &udpw->session->target, result,
+                      udpw->payload_size, overhead);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                  "# UDP, unfragmented msgs, messages, sent, failure",
+                                  1, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, unfragmented msgs, bytes payload, sent, failure",
+                                    udpw->payload_size, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, unfragmented msgs, bytes overhead, sent, failure",
+                                    overhead, GNUNET_NO);
+          break;
+        case MSG_FRAGMENTED_COMPLETE:
+          GNUNET_assert (NULL != udpw->frag_ctx);
+          if (udpw->frag_ctx->cont != NULL)
+            udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls, &udpw->session->target, GNUNET_SYSERR,
+                               udpw->frag_ctx->payload_size, udpw->frag_ctx->on_wire_size);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, messages, sent, failure",
+                                    1, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, bytes payload, sent, failure",
+                                    udpw->payload_size, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, bytes payload, sent, failure",
+                                    overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, bytes payload, sent, failure",
+                                    overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, messages, pending",
+                                    -1, GNUNET_NO);
+          break;
+        case MSG_FRAGMENTED:
+          GNUNET_assert (NULL != udpw->frag_ctx);
+          /* Fragmented message: failed to send */
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, fragments, sent, failure",
+                                    1, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, fragments bytes, sent, failure",
+                                    udpw->msg_size, GNUNET_NO);
+
+          dummy.msg_type = MSG_FRAGMENTED_COMPLETE;
+          dummy.msg_buf = NULL;
+          dummy.msg_size = udpw->frag_ctx->on_wire_size;
+          dummy.payload_size = udpw->frag_ctx->payload_size;
+          dummy.frag_ctx = udpw->frag_ctx;
+          dummy.session = udpw->session;
+          call_continuation (&dummy, GNUNET_SYSERR);
+
+          break;
+        case MSG_ACK:
+          /* ACK message: failed to send */
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, ACK msgs, messages, sent, failure",
+                                    1, GNUNET_NO);
+          break;
+        case MSG_BEACON:
+          /* Beacon message: failed to send */
+          GNUNET_break (0);
+          break;
+        default:
+          GNUNET_break (0);
+          break;
+      }
+      break;
+    default:
+      GNUNET_break (0);
+      break;
+  }
 }
 
 
@@ -730,6 +981,23 @@ free_session (struct Session *s)
 }
 
 
+static void
+dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
+{
+  GNUNET_STATISTICS_update (plugin->env->stats,
+                            "# UDP, total, bytes in buffers",
+                            -udpw->msg_size, GNUNET_NO);
+  GNUNET_STATISTICS_update (plugin->env->stats,
+                            "# UDP, total, msgs in buffers",
+                            -1, GNUNET_NO);
+  if (udpw->session->addrlen == sizeof (struct sockaddr_in))
+    GNUNET_CONTAINER_DLL_remove (plugin->ipv4_queue_head,
+                                 plugin->ipv4_queue_tail, udpw);
+  if (udpw->session->addrlen == sizeof (struct sockaddr_in6))
+    GNUNET_CONTAINER_DLL_remove (plugin->ipv6_queue_head,
+                                 plugin->ipv6_queue_tail, udpw);
+}
+
 /**
  * Functions with this signature are called whenever we need
  * to close a session due to a disconnect or failure to
@@ -740,8 +1008,8 @@ free_session (struct Session *s)
 static void
 disconnect_session (struct Session *s)
 {
-  struct UDPMessageWrapper *udpw;
-  struct UDPMessageWrapper *next;
+  struct UDP_MessageWrapper *udpw;
+  struct UDP_MessageWrapper *next;
 
   GNUNET_assert (GNUNET_YES != s->in_destroy);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -756,7 +1024,7 @@ disconnect_session (struct Session *s)
     next = udpw->next;
     if (udpw->session == s)
     {
-      GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+      dequeue (plugin, udpw);
       call_continuation(udpw, GNUNET_SYSERR);
       GNUNET_free (udpw);
     }
@@ -767,7 +1035,7 @@ disconnect_session (struct Session *s)
     next = udpw->next;
     if (udpw->session == s)
     {
-      GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+      dequeue (plugin, udpw);
       call_continuation(udpw, GNUNET_SYSERR);
       GNUNET_free (udpw);
     }
@@ -779,7 +1047,8 @@ disconnect_session (struct Session *s)
   {
     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));
@@ -791,7 +1060,7 @@ disconnect_session (struct Session *s)
                                                        &s->target.hashPubKey,
                                                        s));
   GNUNET_STATISTICS_set(plugin->env->stats,
-                        "# UDP sessions active",
+                        "# UDP, sessions active",
                         GNUNET_CONTAINER_multihashmap_size(plugin->sessions),
                         GNUNET_NO);
   if (s->rc > 0)
@@ -968,6 +1237,8 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
   s->target = *target;
   s->sock_addr = (const struct sockaddr *) &s[1];
   s->last_expected_delay = GNUNET_TIME_UNIT_SECONDS;
+  s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO_ABS;
+  s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO;
   start_session_timeout (s);
   return s;
 }
@@ -1096,27 +1367,33 @@ udp_plugin_get_session (void *cls,
                                                     &s->target.hashPubKey,
                                                     s,
                                                     GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
-
   GNUNET_STATISTICS_set(plugin->env->stats,
-                        "# UDP sessions active",
+                        "# UDP, sessions active",
                         GNUNET_CONTAINER_multihashmap_size(plugin->sessions),
                         GNUNET_NO);
-
   return s;
 }
 
 
 static void 
-enqueue (struct Plugin *plugin, struct UDPMessageWrapper * udpw)
+enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
 {
-
+  GNUNET_STATISTICS_update (plugin->env->stats,
+                            "# UDP, total, bytes in buffers",
+                            udpw->msg_size, GNUNET_NO);
+  GNUNET_STATISTICS_update (plugin->env->stats,
+                            "# UDP, total, msgs in buffers",
+                            1, GNUNET_NO);
   if (udpw->session->addrlen == sizeof (struct sockaddr_in))
-    GNUNET_CONTAINER_DLL_insert(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+    GNUNET_CONTAINER_DLL_insert (plugin->ipv4_queue_head,
+                                 plugin->ipv4_queue_tail, udpw);
   if (udpw->session->addrlen == sizeof (struct sockaddr_in6))
-    GNUNET_CONTAINER_DLL_insert(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+    GNUNET_CONTAINER_DLL_insert (plugin->ipv6_queue_head,
+                                 plugin->ipv6_queue_tail, udpw);
 }
 
 
+
 /**
  * Fragment message was transmitted via UDP, let fragmentation know
  * to send the next fragment now.
@@ -1124,14 +1401,15 @@ enqueue (struct Plugin *plugin, struct UDPMessageWrapper * udpw)
  * @param cls the 'struct UDPMessageWrapper' of the fragment
  * @param target destination peer (ignored)
  * @param result GNUNET_OK on success (ignored)
+ * @param payload bytes payload sent
+ * @param physical bytes physical sent
  */
 static void
 send_next_fragment (void *cls,
                    const struct GNUNET_PeerIdentity *target,
-                   int result)
+                   int result, size_t payload, size_t physical)
 {
-  struct UDPMessageWrapper *udpw = cls;
-
+  struct UDP_MessageWrapper *udpw = cls;
   GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag);  
 }
 
@@ -1148,23 +1426,25 @@ send_next_fragment (void *cls,
 static void
 enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
 {
-  struct FragmentationContext *frag_ctx = cls;
+  struct UDP_FragmentationContext *frag_ctx = cls;
   struct Plugin *plugin = frag_ctx->plugin;
-  struct UDPMessageWrapper * udpw;
+  struct UDP_MessageWrapper * udpw;
   size_t msg_len = ntohs (msg->size);
  
   LOG (GNUNET_ERROR_TYPE_DEBUG, 
-       "Enqueuing fragment with %u bytes %u\n", msg_len , sizeof (struct UDPMessageWrapper));
-  udpw = GNUNET_malloc (sizeof (struct UDPMessageWrapper) + msg_len);
+       "Enqueuing fragment with %u bytes\n", msg_len);
+  frag_ctx->fragments_used ++;
+  udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len);
   udpw->session = frag_ctx->session;
-  udpw->udp = (char *) &udpw[1];
-
+  udpw->msg_buf = (char *) &udpw[1];
   udpw->msg_size = msg_len;
+  udpw->payload_size = msg_len; /*FIXME: minus fragment overhead */
   udpw->cont = &send_next_fragment;
   udpw->cont_cls = udpw;
   udpw->timeout = frag_ctx->timeout;
   udpw->frag_ctx = frag_ctx;
-  memcpy (udpw->udp, msg, msg_len);
+  udpw->msg_type = MSG_FRAGMENTED;
+  memcpy (udpw->msg_buf, msg, msg_len);
   enqueue (plugin, udpw);
   schedule_select (plugin);
 }
@@ -1206,10 +1486,11 @@ udp_plugin_send (void *cls,
                   GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
 {
   struct Plugin *plugin = cls;
-  size_t mlen = msgbuf_size + sizeof (struct UDPMessage);
-  struct UDPMessageWrapper * udpw;
+  size_t udpmlen = msgbuf_size + sizeof (struct UDPMessage);
+  struct UDP_FragmentationContext * frag_ctx;
+  struct UDP_MessageWrapper * udpw;
   struct UDPMessage *udp;
-  char mbuf[mlen];
+  char mbuf[udpmlen];
   GNUNET_assert (plugin != NULL);
   GNUNET_assert (s != NULL);
 
@@ -1217,7 +1498,7 @@ udp_plugin_send (void *cls,
     return GNUNET_SYSERR;
   if ((s->addrlen == sizeof (struct sockaddr_in)) && (plugin->sockv4 == NULL))
     return GNUNET_SYSERR;
-  if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+  if (udpmlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -1229,59 +1510,80 @@ udp_plugin_send (void *cls,
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "UDP transmits %u-byte message to `%s' using address `%s'\n",
-       mlen,
+       udpmlen,
        GNUNET_i2s (&s->target),
        GNUNET_a2s(s->sock_addr, s->addrlen));
-  
+
+
   /* Message */
   udp = (struct UDPMessage *) mbuf;
-  udp->header.size = htons (mlen);
+  udp->header.size = htons (udpmlen);
   udp->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE);
   udp->reserved = htonl (0);
   udp->sender = *plugin->env->my_identity;
 
   reschedule_session_timeout(s);
-  if (mlen <= UDP_MTU)
+  if (udpmlen <= UDP_MTU)
   {
-    udpw = GNUNET_malloc (sizeof (struct UDPMessageWrapper) + mlen);
+    /* unfragmented message */
+    udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen);
     udpw->session = s;
-    udpw->udp = (char *) &udpw[1];
-    udpw->msg_size = mlen;
+    udpw->msg_buf = (char *) &udpw[1];
+    udpw->msg_size = udpmlen; /* message size with UDP overhead */
+    udpw->payload_size = msgbuf_size; /* message size without UDP overhead */
     udpw->timeout = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), to);
     udpw->cont = cont;
     udpw->cont_cls = cont_cls;
     udpw->frag_ctx = NULL;
-    memcpy (udpw->udp, udp, sizeof (struct UDPMessage));
-    memcpy (&udpw->udp[sizeof (struct UDPMessage)], msgbuf, msgbuf_size);
+    udpw->msg_type = MSG_UNFRAGMENTED;
+    memcpy (udpw->msg_buf, udp, sizeof (struct UDPMessage));
+    memcpy (&udpw->msg_buf[sizeof (struct UDPMessage)], msgbuf, msgbuf_size);
     enqueue (plugin, udpw);
+
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              "# UDP, unfragmented msgs, messages, attempt",
+                              1, GNUNET_NO);
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              "# UDP, unfragmented msgs, bytes payload, attempt",
+                              udpw->payload_size, GNUNET_NO);
   }
   else
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "UDP has to fragment message\n");
+    /* fragmented message */
     if  (s->frag_ctx != NULL)
       return GNUNET_SYSERR;
     memcpy (&udp[1], msgbuf, msgbuf_size);
-    struct FragmentationContext * frag_ctx = GNUNET_malloc(sizeof (struct FragmentationContext));
-
+    frag_ctx = GNUNET_malloc (sizeof (struct UDP_FragmentationContext));
     frag_ctx->plugin = plugin;
     frag_ctx->session = s;
     frag_ctx->cont = cont;
     frag_ctx->cont_cls = cont_cls;
     frag_ctx->timeout = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), to);
-    frag_ctx->bytes_to_send = mlen;
+    frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */
+    frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */
     frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats,
               UDP_MTU,
               &plugin->tracker,
-              s->last_expected_delay,
+              GNUNET_TIME_relative_max (s->last_expected_delay, GNUNET_TIME_UNIT_SECONDS),
               &udp->header,
               &enqueue_fragment,
               frag_ctx);
 
+    frag_ctx->exp_delay = s->last_expected_delay;
     s->frag_ctx = frag_ctx;
+
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              "# UDP, fragmented msgs, messages, pending",
+                              1, GNUNET_NO);
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              "# UDP, fragmented msgs, messages, attempt",
+                              1, GNUNET_NO);
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              "# UDP, fragmented msgs, bytes payload, attempt",
+                              frag_ctx->payload_size, GNUNET_NO);
   }
   schedule_select (plugin);
-  return mlen;
+  return udpmlen;
 }
 
 
@@ -1540,7 +1842,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
   size_t msize = sizeof (struct UDP_ACK_Message) + ntohs (msg->size);
   struct UDP_ACK_Message *udp_ack;
   uint32_t delay = 0;
-  struct UDPMessageWrapper *udpw;
+  struct UDP_MessageWrapper *udpw;
   struct Session *s;
 
   struct LookupContext l_ctx;
@@ -1565,18 +1867,19 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
                     AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct
                                                                      sockaddr_in6)),
        delay);
-  udpw = GNUNET_malloc (sizeof (struct UDPMessageWrapper) + msize);
+  udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize);
   udpw->msg_size = msize;
+  udpw->payload_size = 0;
   udpw->session = s;
   udpw->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
-  udpw->udp = (char *)&udpw[1];
-  udp_ack = (struct UDP_ACK_Message *) udpw->udp;
+  udpw->msg_buf = (char *)&udpw[1];
+  udpw->msg_type = MSG_ACK;
+  udp_ack = (struct UDP_ACK_Message *) udpw->msg_buf;
   udp_ack->header.size = htons ((uint16_t) msize);
   udp_ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK);
   udp_ack->delay = htonl (delay);
   udp_ack->sender = *rc->plugin->env->my_identity;
   memcpy (&udp_ack[1], msg, ntohs (msg->size));
-
   enqueue (rc->plugin, udpw);
 }
 
@@ -1603,6 +1906,9 @@ read_process_ack (struct Plugin *plugin,
                  char *addr,
                  socklen_t fromlen)
 {
+  struct UDP_MessageWrapper dummy;
+  struct UDP_MessageWrapper * udpw;
+  struct UDP_MessageWrapper * tmp;
   const struct GNUNET_MessageHeader *ack;
   const struct UDP_ACK_Message *udp_ack;
   struct LookupContext l_ctx;
@@ -1641,23 +1947,25 @@ read_process_ack (struct Plugin *plugin,
     return;
   }
 
+  if (0 != memcmp (&l_ctx.res->target, &udp_ack->sender, sizeof (struct GNUNET_PeerIdentity)))
+    GNUNET_break (0);
+
   if (GNUNET_OK != GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag, ack))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "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);
 
-  struct UDPMessageWrapper * udpw;
-  struct UDPMessageWrapper * tmp;
   if (s->addrlen == sizeof (struct sockaddr_in6))
   {
     udpw = plugin->ipv6_queue_head;
@@ -1666,7 +1974,7 @@ read_process_ack (struct Plugin *plugin,
       tmp = udpw->next;
       if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx))
       {
-        GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+        dequeue (plugin, udpw);
         GNUNET_free (udpw);
       }
       udpw = tmp;
@@ -1680,20 +1988,29 @@ read_process_ack (struct Plugin *plugin,
       tmp = udpw->next;
       if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx))
       {
-        GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+        dequeue (plugin, udpw);
         GNUNET_free (udpw);
       }
       udpw = tmp;
     }
   }
+/*
+  LOG (GNUNET_ERROR_TYPE_ERROR,
+       "Fragmented message sent: fragments needed: %u , payload %u bytes, used on wire %u bytes, overhead: %f, expected delay: %llu\n",
+       s->frag_ctx->fragments_used,
+       s->frag_ctx->payload_size,
+       s->frag_ctx->on_wire_size,
+       ((float) s->frag_ctx->on_wire_size) / s->frag_ctx->payload_size,
+       s->frag_ctx->exp_delay.rel_value);
+*/
+  dummy.msg_type = MSG_FRAGMENTED_COMPLETE;
+  dummy.msg_buf = NULL;
+  dummy.msg_size = s->frag_ctx->on_wire_size;
+  dummy.payload_size = s->frag_ctx->payload_size;
+  dummy.frag_ctx = s->frag_ctx;
+  dummy.session = s;
 
-  if (s->frag_ctx->cont != NULL)
-  {
-    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);
-  }
+  call_continuation (&dummy, GNUNET_OK);
 
   GNUNET_free (s->frag_ctx);
   s->frag_ctx = NULL;
@@ -1816,6 +2133,10 @@ udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
     return;
   }
 
+  GNUNET_STATISTICS_update (plugin->env->stats,
+                            "# UDP, total, bytes, received",
+                            size, GNUNET_NO);
+
   switch (ntohs (msg->type))
   {
   case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON:
@@ -1840,159 +2161,190 @@ udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
   }
 }
 
-
-static size_t
-udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock)
+static struct UDP_MessageWrapper *
+remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
+                                    struct GNUNET_NETWORK_Handle *sock)
 {
-  ssize_t sent;
-  size_t slen;
-  struct GNUNET_TIME_Absolute max;
-  struct UDPMessageWrapper *udpw = NULL;
-  static int network_down_error;
-
-  if (sock == plugin->sockv4)
-  {
-    udpw = plugin->ipv4_queue_head;
-  }
-  else if (sock == plugin->sockv6)
-  {
-    udpw = plugin->ipv6_queue_head;
-  }
-  else
-  {
-    GNUNET_break (0);
-    return 0;
-  }
-
-  const struct sockaddr * sa = udpw->session->sock_addr;
-  slen = udpw->session->addrlen;
-
-  max = GNUNET_TIME_absolute_max(udpw->timeout, GNUNET_TIME_absolute_get());
+  struct UDP_MessageWrapper *udpw = NULL;
+  struct GNUNET_TIME_Relative remaining;
 
+  udpw = head;
   while (udpw != NULL)
   {
-    if (max.abs_value != udpw->timeout.abs_value)
+    /* Find messages with timeout */
+    remaining = GNUNET_TIME_absolute_get_remaining (udpw->timeout);
+    if (GNUNET_TIME_UNIT_ZERO.rel_value == remaining.rel_value)
     {
       /* Message timed out */
-      call_continuation(udpw, GNUNET_SYSERR);
-      if (udpw->frag_ctx != NULL)
-      {
-        LOG (GNUNET_ERROR_TYPE_DEBUG,
-            "Fragmented message for peer `%s' with size %u timed out\n",
-            GNUNET_i2s(&udpw->session->target), udpw->frag_ctx->bytes_to_send);
-        udpw->session->last_expected_delay = GNUNET_FRAGMENT_context_destroy(udpw->frag_ctx->frag);
-        GNUNET_free (udpw->frag_ctx);
-        udpw->session->frag_ctx = NULL;
-      }
-      else
-      {
-        LOG (GNUNET_ERROR_TYPE_DEBUG, 
-            "Message for peer `%s' with size %u timed out\n",
-            GNUNET_i2s(&udpw->session->target), udpw->msg_size);
+      call_continuation (udpw, GNUNET_SYSERR);
+      switch (udpw->msg_type) {
+        case MSG_UNFRAGMENTED:
+          /* Not fragmented message */
+          LOG (GNUNET_ERROR_TYPE_DEBUG,
+               "Message for peer `%s' with size %u timed out\n",
+               GNUNET_i2s(&udpw->session->target), udpw->payload_size);
+          break;
+        case MSG_FRAGMENTED:
+          /* Fragmented message */
+          call_continuation (udpw, GNUNET_SYSERR);
+          LOG (GNUNET_ERROR_TYPE_DEBUG,
+               "Fragment for message for peer `%s' with size %u timed out\n",
+               GNUNET_i2s(&udpw->session->target), udpw->frag_ctx->payload_size);
+          udpw->session->last_expected_delay = GNUNET_FRAGMENT_context_destroy (udpw->frag_ctx->frag);
+          GNUNET_free (udpw->frag_ctx);
+          udpw->session->frag_ctx = NULL;
+
+          break;
+        case MSG_ACK:
+          LOG (GNUNET_ERROR_TYPE_DEBUG,
+               "ACK Message for peer `%s' with size %u timed out\n",
+               GNUNET_i2s(&udpw->session->target), udpw->payload_size);
+          break;
+        default:
+          break;
       }
 
+      GNUNET_STATISTICS_update (plugin->env->stats,
+                                "# messages dismissed due to timeout",
+                                1, GNUNET_NO);
+      /* Remove message */
       if (sock == plugin->sockv4)
       {
-        GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+        dequeue (plugin, udpw);
         GNUNET_free (udpw);
         udpw = plugin->ipv4_queue_head;
       }
-      else if (sock == plugin->sockv6)
+      if (sock == plugin->sockv6)
       {
-        GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+        dequeue (plugin, udpw);
         GNUNET_free (udpw);
         udpw = plugin->ipv6_queue_head;
       }
     }
     else
     {
-      struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer);
-      if (delta.rel_value == 0)
+      /* Message did not time out, check flow delay */
+      remaining = GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer);
+      if (GNUNET_TIME_UNIT_ZERO.rel_value == remaining.rel_value)
       {
         /* this message is not delayed */
         LOG (GNUNET_ERROR_TYPE_DEBUG, 
-            "Message for peer `%s' (%u bytes) is not delayed \n",
-            GNUNET_i2s(&udpw->session->target), udpw->msg_size);
-        break;
+             "Message for peer `%s' (%u bytes) is not delayed \n",
+             GNUNET_i2s(&udpw->session->target), udpw->payload_size);
+        break; /* Found message to send, break */
       }
       else
       {
-        /* this message is delayed, try next */
+        /* Message is delayed, try next */
         LOG (GNUNET_ERROR_TYPE_DEBUG,
-            "Message for peer `%s' (%u bytes) is delayed for %llu \n",
-            GNUNET_i2s(&udpw->session->target), udpw->msg_size,
-            delta);
+             "Message for peer `%s' (%u bytes) is delayed for %llu \n",
+             GNUNET_i2s(&udpw->session->target), udpw->payload_size, remaining.rel_value);
         udpw = udpw->next;
       }
     }
   }
+  return udpw;
+}
 
-  if (udpw == NULL)
-  {
-    /* No message left */
-    return 0;
-  }
 
-  sent = GNUNET_NETWORK_socket_sendto (sock, udpw->udp, udpw->msg_size, sa, slen);
+static void
+analyze_send_error (struct Plugin *plugin,
+                    const struct sockaddr * sa,
+                    socklen_t slen,
+                    int error)
+{
+  static int network_down_error;
+  struct GNUNET_ATS_Information type;
+
+ type = plugin->env->get_address_type (plugin->env->cls,sa, slen);
+ if (((GNUNET_ATS_NET_LAN == ntohl(type.value)) || (GNUNET_ATS_NET_WAN == ntohl(type.value))) &&
+     ((ENETUNREACH == errno) || (ENETDOWN == errno)))
+ {
+   if ((network_down_error == GNUNET_NO) && (slen == sizeof (struct sockaddr_in)))
+   {
+     /* IPv4: "Network unreachable" or "Network down"
+      *
+      * This indicates we do not have connectivity
+      */
+     LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
+         _("UDP could not transmit message to `%s': "
+           "Network seems down, please check your network configuration\n"),
+         GNUNET_a2s (sa, slen));
+   }
+   if ((network_down_error == GNUNET_NO) && (slen == sizeof (struct sockaddr_in6)))
+   {
+     /* IPv6: "Network unreachable" or "Network down"
+      *
+      * This indicates that this system is IPv6 enabled, but does not
+      * have a valid global IPv6 address assigned or we do not have
+      * connectivity
+      */
+
+    LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
+        _("UDP could not transmit message to `%s': "
+          "Please check your network configuration and disable IPv6 if your "
+          "connection does not have a global IPv6 address\n"),
+        GNUNET_a2s (sa, slen));
+   }
+ }
+ else
+ {
+   LOG (GNUNET_ERROR_TYPE_WARNING,
+      "UDP could not transmit message to `%s': `%s'\n",
+      GNUNET_a2s (sa, slen), STRERROR (error));
+ }
+}
+
+static size_t
+udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock)
+{
+  const struct sockaddr * sa;
+  ssize_t sent;
+  socklen_t slen;
+
+  struct UDP_MessageWrapper *udpw = NULL;
+
+  /* Find message to send */
+  udpw = remove_timeout_messages_and_select ((sock == plugin->sockv4) ? plugin->ipv4_queue_head : plugin->ipv6_queue_head,
+                                             sock);
+  if (NULL == udpw)
+    return 0; /* No message to send */
+
+  sa = udpw->session->sock_addr;
+  slen = udpw->session->addrlen;
+
+  sent = GNUNET_NETWORK_socket_sendto (sock, udpw->msg_buf, udpw->msg_size, sa, slen);
 
   if (GNUNET_SYSERR == sent)
   {
-    const struct GNUNET_ATS_Information type = plugin->env->get_address_type
-        (plugin->env->cls,sa, slen);
-
-    if (((GNUNET_ATS_NET_LAN == ntohl(type.value)) || (GNUNET_ATS_NET_WAN == ntohl(type.value))) &&
-        ((ENETUNREACH == errno) || (ENETDOWN == errno)))
-    {
-      if ((network_down_error == GNUNET_NO) && (slen == sizeof (struct sockaddr_in)))
-      {
-        /* IPv4: "Network unreachable" or "Network down"
-         *
-         * This indicates we do not have connectivity
-         */
-        LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-            _("UDP could not transmit message to `%s': "
-              "Network seems down, please check your network configuration\n"),
-            GNUNET_a2s (sa, slen));
-      }
-      if ((network_down_error == GNUNET_NO) && (slen == sizeof (struct sockaddr_in6)))
-      {
-        /* IPv6: "Network unreachable" or "Network down"
-         *
-         * This indicates that this system is IPv6 enabled, but does not
-         * have a valid global IPv6 address assigned or we do not have
-         * connectivity
-         */
-
-       LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-           _("UDP could not transmit message to `%s': "
-            "Please check your network configuration and disable IPv6 if your "
-            "connection does not have a global IPv6 address\n"),
-          GNUNET_a2s (sa, slen));
-      }
-    }
-    else
-    {
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-         "UDP could not transmit %u-byte message to `%s': `%s'\n",
-         (unsigned int) (udpw->msg_size), GNUNET_a2s (sa, slen),
-         STRERROR (errno));
-    }
+    /* Failure */
+    analyze_send_error (plugin, sa, slen, errno);
     call_continuation(udpw, GNUNET_SYSERR);
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                            "# UDP, total, bytes, sent, failure",
+                            sent, GNUNET_NO);
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              "# UDP, total, messages, sent, failure",
+                              1, GNUNET_NO);
   }
   else
   {
+    /* Success */
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "UDP transmitted %u-byte message to `%s' (%d: %s)\n",
-         (unsigned int) (udpw->msg_size), GNUNET_a2s (sa, slen), (int) sent,
+         "UDP transmitted %u-byte message to  `%s' `%s' (%d: %s)\n",
+         (unsigned int) (udpw->msg_size), GNUNET_i2s(&udpw->session->target) ,GNUNET_a2s (sa, slen), (int) sent,
          (sent < 0) ? STRERROR (errno) : "ok");
-    call_continuation(udpw, GNUNET_OK);
-    network_down_error = GNUNET_NO;
-  }
-
-  if (sock == plugin->sockv4)
-    GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
-  else if (sock == plugin->sockv6)
-    GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              "# UDP, total, bytes, sent, success",
+                              sent, GNUNET_NO);
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              "# UDP, total, messages, sent, success",
+                              1, GNUNET_NO);
+    if (NULL != udpw->frag_ctx)
+        udpw->frag_ctx->on_wire_size += udpw->msg_size;
+    call_continuation (udpw, GNUNET_OK);
+  }
+  dequeue (plugin, udpw);
   GNUNET_free (udpw);
   udpw = NULL;
 
@@ -2329,7 +2681,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
 
   GNUNET_BANDWIDTH_tracker_init (&p->tracker,
                                  GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30);
-  p->sessions = GNUNET_CONTAINER_multihashmap_create (10);
+  p->sessions = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
   p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
   p->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, p);
   p->port = port;
@@ -2454,23 +2806,25 @@ libgnunet_plugin_transport_udp_done (void *cls)
   }
 
   /* Clean up leftover messages */
-  struct UDPMessageWrapper * udpw;
+  struct UDP_MessageWrapper * udpw;
   udpw = plugin->ipv4_queue_head;
   while (udpw != NULL)
   {
-    struct UDPMessageWrapper *tmp = udpw->next;
-    GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+    struct UDP_MessageWrapper *tmp = udpw->next;
+    dequeue (plugin, udpw);
     call_continuation(udpw, GNUNET_SYSERR);
     GNUNET_free (udpw);
+
     udpw = tmp;
   }
   udpw = plugin->ipv6_queue_head;
   while (udpw != NULL)
   {
-    struct UDPMessageWrapper *tmp = udpw->next;
-    GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+    struct UDP_MessageWrapper *tmp = udpw->next;
+    dequeue (plugin, udpw);
     call_continuation(udpw, GNUNET_SYSERR);
     GNUNET_free (udpw);
+
     udpw = tmp;
   }