#include "mesh_path.h"
+#define LOG(level, ...) GNUNET_log_from (level,"mesh-con",__VA_ARGS__)
+
#define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\
GNUNET_TIME_UNIT_MINUTES,\
10)
-#define LOG(level, ...) GNUNET_log_from (level,"mesh-con",__VA_ARGS__)
+#define AVG_MSGS 32
/******************************************************************************/
/******************************** STRUCTS **********************************/
/******************************************************************************/
-/**
- * Struct containing info about a queued transmission to this peer
- */
-struct MeshPeerQueue
-{
- /**
- * DLL next
- */
- struct MeshPeerQueue *next;
-
- /**
- * DLL previous
- */
- struct MeshPeerQueue *prev;
-
- /**
- * Peer this transmission is directed to.
- */
- struct MeshPeer *peer;
-
- /**
- * Connection this message belongs to.
- */
- struct MeshConnection *c;
-
- /**
- * Is FWD in c?
- */
- int fwd;
-
- /**
- * Channel this message belongs to, if known.
- */
- struct MeshChannel *ch;
-
- /**
- * Pointer to info stucture used as cls.
- */
- void *cls;
-
- /**
- * Type of message
- */
- uint16_t type;
-
- /**
- * Size of the message
- */
- size_t size;
-};
-
-
/**
* Struct to encapsulate all the Flow Control information to a peer to which
* we are directly connected (on a core level).
struct GNUNET_TIME_Relative poll_time;
};
+struct MeshConnectionPerformance
+{
+ double secsperbyte[AVG_MSGS];
+
+ unsigned int idx;
+};
+
/**
* Struct containing all information regarding a connection to a peer.
*/
struct MeshFlowControl bck_fc;
+ /**
+ * Measure connection performance on the endpoint.
+ */
+ struct MeshConnectionPerformance *perf;
+
/**
* ID of the connection.
*/
/******************************** STRUCTS **********************************/
/******************************************************************************/
+/**
+ * Struct containing info about a queued transmission to this peer
+ */
+struct MeshPeerQueue
+{
+ /**
+ * DLL next
+ */
+ struct MeshPeerQueue *next;
+
+ /**
+ * DLL previous
+ */
+ struct MeshPeerQueue *prev;
+
+ /**
+ * Peer this transmission is directed to.
+ */
+ struct MeshPeer *peer;
+
+ /**
+ * Connection this message belongs to.
+ */
+ struct MeshConnection *c;
+
+ /**
+ * Is FWD in c?
+ */
+ int fwd;
+
+ /**
+ * Channel this message belongs to, if known.
+ */
+ struct MeshChannel *ch;
+
+ /**
+ * Pointer to info stucture used as cls.
+ */
+ void *cls;
+
+ /**
+ * Type of message
+ */
+ uint16_t type;
+
+ /**
+ * Size of the message
+ */
+ size_t size;
+
+ /**
+ * Set when this message starts waiting for CORE.
+ */
+ struct GNUNET_TIME_Absolute start_waiting;
+
+ /**
+ * Function to call on sending.
+ */
+ GMP_sent callback;
+
+ /**
+ * Closure for callback.
+ */
+ void *callback_cls;
+};
+
/**
* Struct containing all information regarding a given peer
*/
{
struct MeshPeer *aux;
struct MeshPeerPath *copy;
-
+
aux = peer_get_short (p->peers[i]);
copy = path_duplicate (p);
copy->length = i + 1;
}
if (0 < drop_percent &&
- GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent)
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Dropping message of type %s\n",
data_size = 0;
}
+ if (NULL != queue->callback)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "* Calling callback\n");
+ queue->callback (queue->callback_cls,
+ queue->c,
+ GNUNET_TIME_absolute_get_duration (queue->start_waiting));
+ }
+
/* Free queue, but cls was freed by send_core_* */
ch = queue->ch;
- queue_destroy (queue, GNUNET_NO);
+ GMP_queue_destroy (queue, GNUNET_NO);
/* Send ACK if needed, after accounting for sent ID in fc->queue_n */
switch (type)
queue->size,
&queue_send,
peer);
+ queue->start_waiting = GNUNET_TIME_absolute_get ();
}
else
{
* @param c Connection this message belongs to (cannot be NULL).
* @param ch Channel this message belongs to, if applicable (otherwise NULL).
* @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
+ * @param callback Function to be called once CORE has taken the message.
+ * @param callback_cls Closure for @c callback.
*/
void
-GMP_queue_add (void *cls, uint16_t type, size_t size,
+GMP_queue_add (void *cls, uint16_t type, size_t size,
struct MeshConnection *c,
struct MeshChannel *ch,
- int fwd)
+ int fwd,
+ GMP_sent callback, void *callback_cls)
{
struct MeshPeerQueue *queue;
struct MeshFlowControl *fc;
queue->c = c;
queue->ch = ch;
queue->fwd = fwd;
+ queue->callback = callback;
+ queue->callback_cls = callback_cls;
if (100 <= priority)
{
struct MeshPeerQueue *copy;
if (copy->type == type && copy->c == c && copy->fwd == fwd)
{
/* Example: also a FWD ACK for connection XYZ */
- queue_destroy (copy, GNUNET_YES);
+ GMP_queue_destroy (copy, GNUNET_YES);
}
}
GNUNET_CONTAINER_DLL_insert (peer->queue_head, peer->queue_tail, queue);
size,
&queue_send,
peer);
+ queue->start_waiting = GNUNET_TIME_absolute_get ();
}
else
{
{
GMD_search_stop (peer->search_h);
peer->search_h = NULL;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- " Stopping DHT GET for peer %s\n", peer2s (peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ " Stopping DHT GET for peer %s\n",
+ GMP_2s (peer));
}
if (NULL == peer->search_h)
*/
struct MeshPeer;
+/**
+ * Callback called when a queued message is sent.
+ *
+ * @param cls Closure.
+ * @param c Connection this message was on.
+ * @param wait Time spent waiting for core (only the time for THIS message)
+ */
+typedef void (*GMP_sent) (void *cls,
+ struct MeshConnection *c,
+ struct GNUNET_TIME_Relative wait);
+
#include "gnunet-service-mesh_connection.h"
* @param c Connection this message belongs to (cannot be NULL).
* @param ch Channel this message belongs to, if applicable (otherwise NULL).
* @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
+ * @param callback Function to be called once CORE has taken the message.
+ * @param callback_cls Closure for @c callback.
*/
void
GMP_queue_add (void *cls, uint16_t type, size_t size,
struct MeshConnection *c,
struct MeshChannel *ch,
- int fwd);
+ int fwd,
+ GMP_sent callback, void *callback_cls);
/**
* Set tunnel.