aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-08-23 17:02:22 +0000
committerBart Polot <bart@net.in.tum.de>2012-08-23 17:02:22 +0000
commit62ef1190afda79abe69f71cf565a0e738d42e7e5 (patch)
tree07d3a08541ac4551be5fb53d60d9e25561c9791e
parent09f394f4f8fc77de47857adf9b8630136d930005 (diff)
downloadgnunet-62ef1190afda79abe69f71cf565a0e738d42e7e5.tar.gz
gnunet-62ef1190afda79abe69f71cf565a0e738d42e7e5.zip
- multicast flow control
-rw-r--r--src/mesh/gnunet-service-mesh.c63
1 files changed, 52 insertions, 11 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 933ce492a..e7412cb25 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -42,6 +42,7 @@
42 * - relay corking down to core 42 * - relay corking down to core
43 * - set ttl relative to tree depth 43 * - set ttl relative to tree depth
44 * - Add data ACK count in path ACK 44 * - Add data ACK count in path ACK
45 * - Make common GNUNET_MESH_Data header for unicast, to_orig, multicast
45 * TODO END 46 * TODO END
46 */ 47 */
47 48
@@ -3255,7 +3256,7 @@ tunnel_send_multicast_iterator (void *cls, GNUNET_PEER_Id neighbor_id)
3255 3256
3256 3257
3257/** 3258/**
3258 * Send a message in a tunnel in multicast, sending a copy to each child node 3259 * Queue a message in a tunnel in multicast, sending a copy to each child node
3259 * down the local one in the tunnel tree. 3260 * down the local one in the tunnel tree.
3260 * 3261 *
3261 * @param t Tunnel in which to send the data. 3262 * @param t Tunnel in which to send the data.
@@ -3271,6 +3272,7 @@ tunnel_send_multicast (struct MeshTunnel *t,
3271 3272
3272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3273 " sending a multicast packet...\n"); 3274 " sending a multicast packet...\n");
3275
3274 mdata = GNUNET_malloc (sizeof (struct MeshData)); 3276 mdata = GNUNET_malloc (sizeof (struct MeshData));
3275 mdata->data_len = ntohs (msg->size); 3277 mdata->data_len = ntohs (msg->size);
3276 mdata->reference_counter = GNUNET_malloc (sizeof (unsigned int)); 3278 mdata->reference_counter = GNUNET_malloc (sizeof (unsigned int));
@@ -3281,6 +3283,16 @@ tunnel_send_multicast (struct MeshTunnel *t,
3281 { 3283 {
3282 struct GNUNET_MESH_Multicast *mcast; 3284 struct GNUNET_MESH_Multicast *mcast;
3283 3285
3286 if (t->fwd_queue_n >= t->fwd_queue_max)
3287 {
3288 GNUNET_break (0);
3289 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " queue full!\n");
3290 GNUNET_free (mdata->data);
3291 GNUNET_free (mdata->reference_counter);
3292 GNUNET_free (mdata);
3293 return;
3294 }
3295 t->fwd_queue_n++;
3284 mcast = (struct GNUNET_MESH_Multicast *) mdata->data; 3296 mcast = (struct GNUNET_MESH_Multicast *) mdata->data;
3285 mcast->ttl = htonl (ntohl (mcast->ttl) - 1); 3297 mcast->ttl = htonl (ntohl (mcast->ttl) - 1);
3286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " data packet, ttl: %u\n", 3298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " data packet, ttl: %u\n",
@@ -3290,8 +3302,9 @@ tunnel_send_multicast (struct MeshTunnel *t,
3290 { 3302 {
3291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " not a data packet, no ttl\n"); 3303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " not a data packet, no ttl\n");
3292 } 3304 }
3293 if (NULL != t->owner && GNUNET_YES != t->owner->shutting_down 3305 if (NULL != t->owner &&
3294 && GNUNET_NO == internal) 3306 GNUNET_YES != t->owner->shutting_down &&
3307 GNUNET_NO == internal)
3295 { 3308 {
3296 mdata->task = GNUNET_malloc (sizeof (GNUNET_SCHEDULER_TaskIdentifier)); 3309 mdata->task = GNUNET_malloc (sizeof (GNUNET_SCHEDULER_TaskIdentifier));
3297 (*(mdata->task)) = 3310 (*(mdata->task)) =
@@ -3304,6 +3317,9 @@ tunnel_send_multicast (struct MeshTunnel *t,
3304 tree_iterate_children (t->tree, &tunnel_send_multicast_iterator, mdata); 3317 tree_iterate_children (t->tree, &tunnel_send_multicast_iterator, mdata);
3305 if (*(mdata->reference_counter) == 0) 3318 if (*(mdata->reference_counter) == 0)
3306 { 3319 {
3320 GNUNET_break (0);
3321 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3322 " no one to send data to\n");
3307 GNUNET_free (mdata->data); 3323 GNUNET_free (mdata->data);
3308 GNUNET_free (mdata->reference_counter); 3324 GNUNET_free (mdata->reference_counter);
3309 if (NULL != mdata->task) 3325 if (NULL != mdata->task)
@@ -3312,8 +3328,8 @@ tunnel_send_multicast (struct MeshTunnel *t,
3312 GNUNET_free (mdata->task); 3328 GNUNET_free (mdata->task);
3313 GNUNET_SERVER_receive_done (t->owner->handle, GNUNET_OK); 3329 GNUNET_SERVER_receive_done (t->owner->handle, GNUNET_OK);
3314 } 3330 }
3315 // FIXME change order?
3316 GNUNET_free (mdata); 3331 GNUNET_free (mdata);
3332 t->fwd_queue_n--;
3317 } 3333 }
3318 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3334 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3319 " sending a multicast packet done\n"); 3335 " sending a multicast packet done\n");
@@ -4366,29 +4382,50 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
4366 * NULL when there are no transmittable messages. 4382 * NULL when there are no transmittable messages.
4367 */ 4383 */
4368struct MeshPeerQueue * 4384struct MeshPeerQueue *
4369queue_get_next (static struct MeshPeerInfo *peer) 4385queue_get_next (const struct MeshPeerInfo *peer)
4370{ 4386{
4371 struct MeshPeerQueue *q; 4387 struct MeshPeerQueue *q;
4372 struct MeshTunnel *t; 4388 struct MeshTunnel *t;
4373 struct MeshTransmissionDescriptor *info; 4389 struct MeshTransmissionDescriptor *info;
4390 struct MeshTunnelChildInfo *cinfo;
4391 struct GNUNET_MESH_Unicast *ucast;
4392 struct GNUNET_MESH_ToOrigin *to_orig;
4393 struct GNUNET_MESH_Multicast *mcast;
4394 struct GNUNET_PeerIdentity id;
4395 uint32_t pid;
4396 uint32_t ack;
4374 4397
4375 for (q = peer->queue_head; NULL != q; q = q->next) 4398 for (q = peer->queue_head; NULL != q; q = q->next)
4376 { 4399 {
4377 t = q->tunnel; 4400 t = q->tunnel;
4401 info = q->cls;
4378 switch (q->type) 4402 switch (q->type)
4379 { 4403 {
4380 case GNUNET_MESSAGE_TYPE_MESH_UNICAST: 4404 case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
4381 info = q->cls; 4405 ucast = (struct GNUNET_MESH_Unicast *) info->mesh_data->data;
4406 pid = ntohl (ucast->pid);
4407 GNUNET_PEER_resolve (info->peer->id, &id);
4408 cinfo = tunnel_get_neighbor_fc(t, &id);
4409 ack = cinfo->fwd_ack;
4382 break; 4410 break;
4383 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: 4411 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
4412 to_orig = (struct GNUNET_MESH_ToOrigin *) info->mesh_data->data;
4413 pid = ntohl (to_orig->pid);
4414 ack = t->bck_ack;
4384 break; 4415 break;
4385 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST: 4416 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
4417 mcast = (struct GNUNET_MESH_Multicast *) info->mesh_data->data;
4418 pid = ntohl (mcast->pid);
4419 GNUNET_PEER_resolve (info->peer->id, &id);
4420 cinfo = tunnel_get_neighbor_fc(t, &id);
4421 ack = cinfo->fwd_ack;
4386 break; 4422 break;
4387 default: 4423 default:
4388 return q; 4424 return q;
4389 } 4425 }
4426 if (GNUNET_NO == GMC_is_pid_bigger(pid, ack))
4427 return q;
4390 } 4428 }
4391 // FIXME fc WIP
4392 return NULL; 4429 return NULL;
4393} 4430}
4394 4431
@@ -4412,15 +4449,16 @@ queue_send (void *cls, size_t size, void *buf)
4412 size_t data_size; 4449 size_t data_size;
4413 4450
4414 peer->core_transmit = NULL; 4451 peer->core_transmit = NULL;
4415 queue = peer->queue_head; 4452 queue = queue_get_next(peer);
4416 4453
4417 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Queue send\n"); 4454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Queue send\n");
4418 4455
4419 /* If queue is empty, send should have been cancelled */ 4456 /* Queue has no internal mesh traffic not sendable payload */
4420 if (NULL == queue) 4457 if (NULL == queue)
4421 { 4458 {
4422 GNUNET_break(0); 4459 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not ready, return\n");
4423 return 0; 4460 GNUNET_break(0);
4461 return 0;
4424 } 4462 }
4425 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not empty\n"); 4463 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not empty\n");
4426 4464
@@ -4429,6 +4467,8 @@ queue_send (void *cls, size_t size, void *buf)
4429 { 4467 {
4430 struct GNUNET_PeerIdentity id; 4468 struct GNUNET_PeerIdentity id;
4431 4469
4470 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4471 "********* not enough room, reissue\n");
4432 GNUNET_PEER_resolve (peer->id, &id); 4472 GNUNET_PEER_resolve (peer->id, &id);
4433 peer->core_transmit = 4473 peer->core_transmit =
4434 GNUNET_CORE_notify_transmit_ready(core_handle, 4474 GNUNET_CORE_notify_transmit_ready(core_handle,
@@ -4487,6 +4527,7 @@ queue_send (void *cls, size_t size, void *buf)
4487 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST: 4527 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
4488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* multicast\n"); 4528 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* multicast\n");
4489 data_size = send_core_data_multicast(queue->cls, size, buf); 4529 data_size = send_core_data_multicast(queue->cls, size, buf);
4530 // t->fwd_queue_n--; FIXME fc
4490 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_MULTICAST); 4531 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_MULTICAST);
4491 break; 4532 break;
4492 case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: 4533 case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: