aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-08-02 15:04:44 +0000
committerBart Polot <bart@net.in.tum.de>2012-08-02 15:04:44 +0000
commit13aa3b5afa5e7a77c84f23fa6f67d657f8cf8499 (patch)
tree152e4946686409950cb5235f48ec3265246c250e /src/mesh/gnunet-service-mesh.c
parent72c964fc395fc7037acaf5f220b2e8e0a2427be2 (diff)
downloadgnunet-13aa3b5afa5e7a77c84f23fa6f67d657f8cf8499.tar.gz
gnunet-13aa3b5afa5e7a77c84f23fa6f67d657f8cf8499.zip
-m fix client FWD ACK
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r--src/mesh/gnunet-service-mesh.c100
1 files changed, 63 insertions, 37 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 2f38864c8..2b822db99 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -261,29 +261,6 @@ struct MESH_TunnelID
261 261
262 262
263/** 263/**
264 * Info collected during iteration of child nodes in order to get the ACK value
265 * for a tunnel.
266 */
267struct MeshTunnelChildIteratorContext
268{
269 /**
270 * Tunnel whose info is being collected.
271 */
272 struct MeshTunnel *t;
273
274 /**
275 * Maximum child ACK so far.
276 */
277 uint32_t max_child_ack;
278
279 /**
280 * Number of children nodes
281 */
282 unsigned int nchildren;
283};
284
285
286/**
287 * Struct containing all information regarding a tunnel 264 * Struct containing all information regarding a tunnel
288 * For an intermediate node the improtant info used will be: 265 * For an intermediate node the improtant info used will be:
289 * - id Tunnel unique identification 266 * - id Tunnel unique identification
@@ -388,11 +365,18 @@ struct MeshTunnel
388 struct MeshClient **clients; 365 struct MeshClient **clients;
389 366
390 /** 367 /**
391 * ACK value of each active client. 368 * FWD ACK value of each active client: up to what message can we transmit
369 * to a leaf client.
392 */ 370 */
393 uint32_t *clients_acks; 371 uint32_t *clients_acks;
394 372
395 /** 373 /**
374 * BCK ACK value of the root client, owner of the tunnel,
375 * up to what message PID can we sent him.
376 */
377 uint32_t root_client_ack;
378
379 /**
396 * Number of elements in clients/clients_acks 380 * Number of elements in clients/clients_acks
397 */ 381 */
398 unsigned int nclients; 382 unsigned int nclients;
@@ -468,7 +452,7 @@ struct MeshTunnelChildInfo
468 GNUNET_PEER_Id id; 452 GNUNET_PEER_Id id;
469 453
470 /** 454 /**
471 * SKIP value 455 * SKIP value.
472 */ 456 */
473 uint32_t skip; 457 uint32_t skip;
474 458
@@ -483,6 +467,30 @@ struct MeshTunnelChildInfo
483 uint32_t max_pid; 467 uint32_t max_pid;
484}; 468};
485 469
470
471/**
472 * Info collected during iteration of child nodes in order to get the ACK value
473 * for a tunnel.
474 */
475struct MeshTunnelChildIteratorContext
476{
477 /**
478 * Tunnel whose info is being collected.
479 */
480 struct MeshTunnel *t;
481
482 /**
483 * Maximum child ACK so far.
484 */
485 uint32_t max_child_ack;
486
487 /**
488 * Number of children nodes
489 */
490 unsigned int nchildren;
491};
492
493
486/** 494/**
487 * Info needed to work with tunnel paths and peers 495 * Info needed to work with tunnel paths and peers
488 */ 496 */
@@ -2023,16 +2031,18 @@ send_client_peer_connected (const struct MeshTunnel *t, const GNUNET_PEER_Id id)
2023 2031
2024 2032
2025/** 2033/**
2026 * Notify a client about how many more payload packages will we accept 2034 * Notify a the client of a tunnel about how many more
2027 * on a given tunnel. 2035 * payload packages will we accept on a given tunnel,
2036 * distinguiching between root and leaf clients.
2028 * 2037 *
2029 * @param c Client. 2038 * @param c Client whom to send the ACK.
2030 * @param t Tunnel. 2039 * @param t Tunnel on which to send the ACK.
2031 */ 2040 */
2032static void 2041static void
2033send_client_tunnel_ack (struct MeshClient *c, struct MeshTunnel *t) 2042send_client_tunnel_ack (struct MeshClient *c, struct MeshTunnel *t)
2034{ 2043{
2035 struct GNUNET_MESH_LocalAck msg; 2044 struct GNUNET_MESH_LocalAck msg;
2045 MESH_TunnelNumber tid;
2036 uint32_t ack; 2046 uint32_t ack;
2037 2047
2038 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2048 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2043,7 +2053,18 @@ send_client_tunnel_ack (struct MeshClient *c, struct MeshTunnel *t)
2043 2053
2044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " to client %u\n", c->id); 2054 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " to client %u\n", c->id);
2045 2055
2046 ack = tunnel_get_fwd_ack (t); 2056 if (c == t->owner)
2057 {
2058 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " (owner, FWD ACK)\n");
2059 ack = tunnel_get_fwd_ack (t);
2060 tid = t->local_tid;
2061 }
2062 else
2063 {
2064 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " (leaf, BCK ACK)\n");
2065 ack = tunnel_get_bck_ack (t);
2066 tid = t->local_tid_dest;
2067 }
2047 2068
2048 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ack %u\n", ack); 2069 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ack %u\n", ack);
2049 if (t->last_ack == ack) 2070 if (t->last_ack == ack)
@@ -2053,7 +2074,7 @@ send_client_tunnel_ack (struct MeshClient *c, struct MeshTunnel *t)
2053 t->last_ack = ack; 2074 t->last_ack = ack;
2054 msg.header.size = htons (sizeof (msg)); 2075 msg.header.size = htons (sizeof (msg));
2055 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK); 2076 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK);
2056 msg.tunnel_id = htonl (t->local_tid); 2077 msg.tunnel_id = htonl (tid);
2057 msg.max_pid = htonl (ack); 2078 msg.max_pid = htonl (ack);
2058 2079
2059 GNUNET_SERVER_notification_context_unicast (nc, c->handle, 2080 GNUNET_SERVER_notification_context_unicast (nc, c->handle,
@@ -3408,9 +3429,9 @@ tunnel_add_client (struct MeshTunnel *t, struct MeshClient *c)
3408 * @param ack ACK value. 3429 * @param ack ACK value.
3409 */ 3430 */
3410static void 3431static void
3411tunnel_set_client_ack (struct MeshTunnel *t, 3432tunnel_set_client_fwd_ack (struct MeshTunnel *t,
3412 struct MeshClient *c, 3433 struct MeshClient *c,
3413 uint32_t ack) 3434 uint32_t ack)
3414{ 3435{
3415 unsigned int i; 3436 unsigned int i;
3416 3437
@@ -3852,6 +3873,7 @@ tunnel_new (GNUNET_PEER_Id owner,
3852 t->queue_max = (max_msgs_queue / max_tunnels) + 1; 3873 t->queue_max = (max_msgs_queue / max_tunnels) + 1;
3853 t->tree = tree_new (owner); 3874 t->tree = tree_new (owner);
3854 t->owner = client; 3875 t->owner = client;
3876 t->root_client_ack = 1;
3855 t->local_tid = local; 3877 t->local_tid = local;
3856 t->children_fc = GNUNET_CONTAINER_multihashmap_create (8); 3878 t->children_fc = GNUNET_CONTAINER_multihashmap_create (8);
3857 n_tunnels++; 3879 n_tunnels++;
@@ -6742,7 +6764,7 @@ handle_local_multicast (void *cls, struct GNUNET_SERVER_Client *client,
6742 6764
6743 6765
6744/** 6766/**
6745 * Handler for client ACKs for payload traffic. 6767 * Handler for client's ACKs for payload traffic.
6746 * 6768 *
6747 * @param cls Closure (unused). 6769 * @param cls Closure (unused).
6748 * @param client Identification of the client. 6770 * @param client Identification of the client.
@@ -6757,6 +6779,7 @@ handle_local_ack (void *cls, struct GNUNET_SERVER_Client *client,
6757 struct MeshClient *c; 6779 struct MeshClient *c;
6758 MESH_TunnelNumber tid; 6780 MESH_TunnelNumber tid;
6759 6781
6782 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a local ACK\n");
6760 /* Sanity check for client registration */ 6783 /* Sanity check for client registration */
6761 if (NULL == (c = client_get (client))) 6784 if (NULL == (c = client_get (client)))
6762 { 6785 {
@@ -6768,6 +6791,7 @@ handle_local_ack (void *cls, struct GNUNET_SERVER_Client *client,
6768 msg = (struct GNUNET_MESH_LocalAck *) message; 6791 msg = (struct GNUNET_MESH_LocalAck *) message;
6769 /* Tunnel exists? */ 6792 /* Tunnel exists? */
6770 tid = ntohl (msg->tunnel_id); 6793 tid = ntohl (msg->tunnel_id);
6794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " on tunnel %X\n", tid);
6771 t = tunnel_get_by_local_id (c, tid); 6795 t = tunnel_get_by_local_id (c, tid);
6772 if (NULL == t) 6796 if (NULL == t)
6773 { 6797 {
@@ -6776,7 +6800,7 @@ handle_local_ack (void *cls, struct GNUNET_SERVER_Client *client,
6776 return; 6800 return;
6777 } 6801 }
6778 6802
6779 /* Does client own tunnel? */ 6803 /* Does client own tunnel? Is this and ACK for BCK traffic? */
6780 if (NULL != t->owner && t->owner->handle == client) 6804 if (NULL != t->owner && t->owner->handle == client)
6781 { 6805 {
6782 GNUNET_break (0); 6806 GNUNET_break (0);
@@ -6784,7 +6808,9 @@ handle_local_ack (void *cls, struct GNUNET_SERVER_Client *client,
6784 } 6808 }
6785 else 6809 else
6786 { 6810 {
6787 tunnel_set_client_ack (t, c, ntohl (msg->max_pid)); 6811 /* The client doesn't own the tunnel, this ACK is for FWD traffic. */
6812 tunnel_set_client_fwd_ack (t, c, ntohl (msg->max_pid));
6813 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST);
6788 } 6814 }
6789 6815
6790 GNUNET_SERVER_receive_done (client, GNUNET_OK); 6816 GNUNET_SERVER_receive_done (client, GNUNET_OK);