aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesh/gnunet-service-mesh_connection.c68
-rw-r--r--src/mesh/gnunet-service-mesh_peer.c98
-rw-r--r--src/mesh/gnunet-service-mesh_peer.h16
3 files changed, 120 insertions, 62 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c
index 20f122ded..1320c7837 100644
--- a/src/mesh/gnunet-service-mesh_connection.c
+++ b/src/mesh/gnunet-service-mesh_connection.c
@@ -37,10 +37,12 @@
37#include "mesh_path.h" 37#include "mesh_path.h"
38 38
39 39
40#define LOG(level, ...) GNUNET_log_from (level,"mesh-con",__VA_ARGS__)
41
40#define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\ 42#define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\
41 GNUNET_TIME_UNIT_MINUTES,\ 43 GNUNET_TIME_UNIT_MINUTES,\
42 10) 44 10)
43#define LOG(level, ...) GNUNET_log_from (level,"mesh-con",__VA_ARGS__) 45#define AVG_MSGS 32
44 46
45 47
46/******************************************************************************/ 48/******************************************************************************/
@@ -48,58 +50,6 @@
48/******************************************************************************/ 50/******************************************************************************/
49 51
50/** 52/**
51 * Struct containing info about a queued transmission to this peer
52 */
53struct MeshPeerQueue
54{
55 /**
56 * DLL next
57 */
58 struct MeshPeerQueue *next;
59
60 /**
61 * DLL previous
62 */
63 struct MeshPeerQueue *prev;
64
65 /**
66 * Peer this transmission is directed to.
67 */
68 struct MeshPeer *peer;
69
70 /**
71 * Connection this message belongs to.
72 */
73 struct MeshConnection *c;
74
75 /**
76 * Is FWD in c?
77 */
78 int fwd;
79
80 /**
81 * Channel this message belongs to, if known.
82 */
83 struct MeshChannel *ch;
84
85 /**
86 * Pointer to info stucture used as cls.
87 */
88 void *cls;
89
90 /**
91 * Type of message
92 */
93 uint16_t type;
94
95 /**
96 * Size of the message
97 */
98 size_t size;
99};
100
101
102/**
103 * Struct to encapsulate all the Flow Control information to a peer to which 53 * Struct to encapsulate all the Flow Control information to a peer to which
104 * we are directly connected (on a core level). 54 * we are directly connected (on a core level).
105 */ 55 */
@@ -156,6 +106,13 @@ struct MeshFlowControl
156 struct GNUNET_TIME_Relative poll_time; 106 struct GNUNET_TIME_Relative poll_time;
157}; 107};
158 108
109struct MeshConnectionPerformance
110{
111 double secsperbyte[AVG_MSGS];
112
113 unsigned int idx;
114};
115
159 116
160/** 117/**
161 * Struct containing all information regarding a connection to a peer. 118 * Struct containing all information regarding a connection to a peer.
@@ -178,6 +135,11 @@ struct MeshConnection
178 struct MeshFlowControl bck_fc; 135 struct MeshFlowControl bck_fc;
179 136
180 /** 137 /**
138 * Measure connection performance on the endpoint.
139 */
140 struct MeshConnectionPerformance *perf;
141
142 /**
181 * ID of the connection. 143 * ID of the connection.
182 */ 144 */
183 struct GNUNET_HashCode id; 145 struct GNUNET_HashCode id;
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c
index 2c3967d8a..d700f3aa2 100644
--- a/src/mesh/gnunet-service-mesh_peer.c
+++ b/src/mesh/gnunet-service-mesh_peer.c
@@ -41,6 +41,72 @@
41/******************************************************************************/ 41/******************************************************************************/
42 42
43/** 43/**
44 * Struct containing info about a queued transmission to this peer
45 */
46struct MeshPeerQueue
47{
48 /**
49 * DLL next
50 */
51 struct MeshPeerQueue *next;
52
53 /**
54 * DLL previous
55 */
56 struct MeshPeerQueue *prev;
57
58 /**
59 * Peer this transmission is directed to.
60 */
61 struct MeshPeer *peer;
62
63 /**
64 * Connection this message belongs to.
65 */
66 struct MeshConnection *c;
67
68 /**
69 * Is FWD in c?
70 */
71 int fwd;
72
73 /**
74 * Channel this message belongs to, if known.
75 */
76 struct MeshChannel *ch;
77
78 /**
79 * Pointer to info stucture used as cls.
80 */
81 void *cls;
82
83 /**
84 * Type of message
85 */
86 uint16_t type;
87
88 /**
89 * Size of the message
90 */
91 size_t size;
92
93 /**
94 * Set when this message starts waiting for CORE.
95 */
96 struct GNUNET_TIME_Absolute start_waiting;
97
98 /**
99 * Function to call on sending.
100 */
101 GMP_sent callback;
102
103 /**
104 * Closure for callback.
105 */
106 void *callback_cls;
107};
108
109/**
44 * Struct containing all information regarding a given peer 110 * Struct containing all information regarding a given peer
45 */ 111 */
46struct MeshPeer 112struct MeshPeer
@@ -822,7 +888,7 @@ path_add_to_peers (struct MeshPeerPath *p, int confirmed)
822 { 888 {
823 struct MeshPeer *aux; 889 struct MeshPeer *aux;
824 struct MeshPeerPath *copy; 890 struct MeshPeerPath *copy;
825 891
826 aux = peer_get_short (p->peers[i]); 892 aux = peer_get_short (p->peers[i]);
827 copy = path_duplicate (p); 893 copy = path_duplicate (p);
828 copy->length = i + 1; 894 copy->length = i + 1;
@@ -977,7 +1043,7 @@ queue_send (void *cls, size_t size, void *buf)
977 } 1043 }
978 1044
979 if (0 < drop_percent && 1045 if (0 < drop_percent &&
980 GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent) 1046 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent)
981 { 1047 {
982 LOG (GNUNET_ERROR_TYPE_WARNING, 1048 LOG (GNUNET_ERROR_TYPE_WARNING,
983 "Dropping message of type %s\n", 1049 "Dropping message of type %s\n",
@@ -985,9 +1051,17 @@ queue_send (void *cls, size_t size, void *buf)
985 data_size = 0; 1051 data_size = 0;
986 } 1052 }
987 1053
1054 if (NULL != queue->callback)
1055 {
1056 LOG (GNUNET_ERROR_TYPE_DEBUG, "* Calling callback\n");
1057 queue->callback (queue->callback_cls,
1058 queue->c,
1059 GNUNET_TIME_absolute_get_duration (queue->start_waiting));
1060 }
1061
988 /* Free queue, but cls was freed by send_core_* */ 1062 /* Free queue, but cls was freed by send_core_* */
989 ch = queue->ch; 1063 ch = queue->ch;
990 queue_destroy (queue, GNUNET_NO); 1064 GMP_queue_destroy (queue, GNUNET_NO);
991 1065
992 /* Send ACK if needed, after accounting for sent ID in fc->queue_n */ 1066 /* Send ACK if needed, after accounting for sent ID in fc->queue_n */
993 switch (type) 1067 switch (type)
@@ -1018,6 +1092,7 @@ queue_send (void *cls, size_t size, void *buf)
1018 queue->size, 1092 queue->size,
1019 &queue_send, 1093 &queue_send,
1020 peer); 1094 peer);
1095 queue->start_waiting = GNUNET_TIME_absolute_get ();
1021 } 1096 }
1022 else 1097 else
1023 { 1098 {
@@ -1193,12 +1268,15 @@ GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
1193 * @param c Connection this message belongs to (cannot be NULL). 1268 * @param c Connection this message belongs to (cannot be NULL).
1194 * @param ch Channel this message belongs to, if applicable (otherwise NULL). 1269 * @param ch Channel this message belongs to, if applicable (otherwise NULL).
1195 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!) 1270 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
1271 * @param callback Function to be called once CORE has taken the message.
1272 * @param callback_cls Closure for @c callback.
1196 */ 1273 */
1197void 1274void
1198GMP_queue_add (void *cls, uint16_t type, size_t size, 1275GMP_queue_add (void *cls, uint16_t type, size_t size,
1199 struct MeshConnection *c, 1276 struct MeshConnection *c,
1200 struct MeshChannel *ch, 1277 struct MeshChannel *ch,
1201 int fwd) 1278 int fwd,
1279 GMP_sent callback, void *callback_cls)
1202{ 1280{
1203 struct MeshPeerQueue *queue; 1281 struct MeshPeerQueue *queue;
1204 struct MeshFlowControl *fc; 1282 struct MeshFlowControl *fc;
@@ -1274,6 +1352,8 @@ GMP_queue_add (void *cls, uint16_t type, size_t size,
1274 queue->c = c; 1352 queue->c = c;
1275 queue->ch = ch; 1353 queue->ch = ch;
1276 queue->fwd = fwd; 1354 queue->fwd = fwd;
1355 queue->callback = callback;
1356 queue->callback_cls = callback_cls;
1277 if (100 <= priority) 1357 if (100 <= priority)
1278 { 1358 {
1279 struct MeshPeerQueue *copy; 1359 struct MeshPeerQueue *copy;
@@ -1285,7 +1365,7 @@ GMP_queue_add (void *cls, uint16_t type, size_t size,
1285 if (copy->type == type && copy->c == c && copy->fwd == fwd) 1365 if (copy->type == type && copy->c == c && copy->fwd == fwd)
1286 { 1366 {
1287 /* Example: also a FWD ACK for connection XYZ */ 1367 /* Example: also a FWD ACK for connection XYZ */
1288 queue_destroy (copy, GNUNET_YES); 1368 GMP_queue_destroy (copy, GNUNET_YES);
1289 } 1369 }
1290 } 1370 }
1291 GNUNET_CONTAINER_DLL_insert (peer->queue_head, peer->queue_tail, queue); 1371 GNUNET_CONTAINER_DLL_insert (peer->queue_head, peer->queue_tail, queue);
@@ -1312,6 +1392,7 @@ GMP_queue_add (void *cls, uint16_t type, size_t size,
1312 size, 1392 size,
1313 &queue_send, 1393 &queue_send,
1314 peer); 1394 peer);
1395 queue->start_waiting = GNUNET_TIME_absolute_get ();
1315 } 1396 }
1316 else 1397 else
1317 { 1398 {
@@ -1457,8 +1538,9 @@ GMP_connect (struct MeshPeer *peer)
1457 { 1538 {
1458 GMD_search_stop (peer->search_h); 1539 GMD_search_stop (peer->search_h);
1459 peer->search_h = NULL; 1540 peer->search_h = NULL;
1460 LOG (GNUNET_ERROR_TYPE_DEBUG, 1541 LOG (GNUNET_ERROR_TYPE_DEBUG,
1461 " Stopping DHT GET for peer %s\n", peer2s (peer)); 1542 " Stopping DHT GET for peer %s\n",
1543 GMP_2s (peer));
1462 } 1544 }
1463 1545
1464 if (NULL == peer->search_h) 1546 if (NULL == peer->search_h)
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h
index 065da7731..8280d16d2 100644
--- a/src/mesh/gnunet-service-mesh_peer.h
+++ b/src/mesh/gnunet-service-mesh_peer.h
@@ -45,6 +45,17 @@ extern "C"
45 */ 45 */
46struct MeshPeer; 46struct MeshPeer;
47 47
48/**
49 * Callback called when a queued message is sent.
50 *
51 * @param cls Closure.
52 * @param c Connection this message was on.
53 * @param wait Time spent waiting for core (only the time for THIS message)
54 */
55typedef void (*GMP_sent) (void *cls,
56 struct MeshConnection *c,
57 struct GNUNET_TIME_Relative wait);
58
48#include "gnunet-service-mesh_connection.h" 59#include "gnunet-service-mesh_connection.h"
49 60
50 61
@@ -76,12 +87,15 @@ GMP_shutdown (void);
76 * @param c Connection this message belongs to (cannot be NULL). 87 * @param c Connection this message belongs to (cannot be NULL).
77 * @param ch Channel this message belongs to, if applicable (otherwise NULL). 88 * @param ch Channel this message belongs to, if applicable (otherwise NULL).
78 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!) 89 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
90 * @param callback Function to be called once CORE has taken the message.
91 * @param callback_cls Closure for @c callback.
79 */ 92 */
80void 93void
81GMP_queue_add (void *cls, uint16_t type, size_t size, 94GMP_queue_add (void *cls, uint16_t type, size_t size,
82 struct MeshConnection *c, 95 struct MeshConnection *c,
83 struct MeshChannel *ch, 96 struct MeshChannel *ch,
84 int fwd); 97 int fwd,
98 GMP_sent callback, void *callback_cls);
85 99
86/** 100/**
87 * Set tunnel. 101 * Set tunnel.