aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-11-26 11:03:18 +0000
committerNathan S. Evans <evans@in.tum.de>2010-11-26 11:03:18 +0000
commit26c8d636296f130c9da010fdd1dfe3643ffac346 (patch)
tree0a8fa5276e943d1295cae237ec97c0b28ea3e880
parent72848f78d9f4b45cd1c5df9f4b85cc9d8a536ec9 (diff)
downloadgnunet-26c8d636296f130c9da010fdd1dfe3643ffac346.tar.gz
gnunet-26c8d636296f130c9da010fdd1dfe3643ffac346.zip
are messages getting dropped, or is logging not finding all paths
-rw-r--r--src/dht/gnunet-service-dht.c104
1 files changed, 75 insertions, 29 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 224ac6c46..745392456 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -2600,7 +2600,19 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg,
2600 put_type = (enum GNUNET_BLOCK_Type) ntohl (put_msg->type); 2600 put_type = (enum GNUNET_BLOCK_Type) ntohl (put_msg->type);
2601#if HAVE_MALICIOUS 2601#if HAVE_MALICIOUS
2602 if (put_type == GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE) 2602 if (put_type == GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE)
2603 return; 2603 {
2604#if DEBUG_DHT_ROUTING
2605 if ((debug_routes_extended) && (dhtlog_handle != NULL))
2606 {
2607 /** Log routes that die due to high load! */
2608 dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE,
2609 msg_ctx->hop_count, GNUNET_SYSERR,
2610 &my_identity, &msg_ctx->key, msg_ctx->peer,
2611 NULL);
2612 }
2613#endif
2614 return;
2615 }
2604#endif 2616#endif
2605 data_size = ntohs (put_msg->header.size) - sizeof (struct GNUNET_DHT_PutMessage); 2617 data_size = ntohs (put_msg->header.size) - sizeof (struct GNUNET_DHT_PutMessage);
2606 ret = GNUNET_BLOCK_get_key (block_context, 2618 ret = GNUNET_BLOCK_get_key (block_context,
@@ -2610,6 +2622,16 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg,
2610 &key); 2622 &key);
2611 if (GNUNET_NO == ret) 2623 if (GNUNET_NO == ret)
2612 { 2624 {
2625#if DEBUG_DHT_ROUTING
2626 if ((debug_routes_extended) && (dhtlog_handle != NULL))
2627 {
2628 /** Log routes that die due to high load! */
2629 dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE,
2630 msg_ctx->hop_count, GNUNET_SYSERR,
2631 &my_identity, &msg_ctx->key, msg_ctx->peer,
2632 NULL);
2633 }
2634#endif
2613 /* invalid reply */ 2635 /* invalid reply */
2614 GNUNET_break_op (0); 2636 GNUNET_break_op (0);
2615 return; 2637 return;
@@ -2619,6 +2641,16 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg,
2619 &msg_ctx->key, 2641 &msg_ctx->key,
2620 sizeof (GNUNET_HashCode))) ) 2642 sizeof (GNUNET_HashCode))) )
2621 { 2643 {
2644#if DEBUG_DHT_ROUTING
2645 if ((debug_routes_extended) && (dhtlog_handle != NULL))
2646 {
2647 /** Log routes that die due to high load! */
2648 dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE,
2649 msg_ctx->hop_count, GNUNET_SYSERR,
2650 &my_identity, &msg_ctx->key, msg_ctx->peer,
2651 NULL);
2652 }
2653#endif
2622 /* invalid wrapper: key mismatch! */ 2654 /* invalid wrapper: key mismatch! */
2623 GNUNET_break_op (0); 2655 GNUNET_break_op (0);
2624 return; 2656 return;
@@ -3441,6 +3473,7 @@ route_message(const struct GNUNET_MessageHeader *msg,
3441#if DEBUG_DHT_ROUTING > 1 3473#if DEBUG_DHT_ROUTING > 1
3442 struct PeerInfo *nearest; 3474 struct PeerInfo *nearest;
3443#endif 3475#endif
3476 unsigned int target_forward_count;
3444 unsigned int forward_count; 3477 unsigned int forward_count;
3445 struct RecentRequest *recent_req; 3478 struct RecentRequest *recent_req;
3446 GNUNET_HashCode unique_hash; 3479 GNUNET_HashCode unique_hash;
@@ -3470,15 +3503,15 @@ route_message(const struct GNUNET_MessageHeader *msg,
3470 } 3503 }
3471 3504
3472 increment_stats(STAT_ROUTES); 3505 increment_stats(STAT_ROUTES);
3473 forward_count = get_forward_count(msg_ctx->hop_count, msg_ctx->replication); 3506 target_forward_count = get_forward_count(msg_ctx->hop_count, msg_ctx->replication);
3474 GNUNET_asprintf(&stat_forward_count, "# forward counts of %d", forward_count); 3507 GNUNET_asprintf(&stat_forward_count, "# forward counts of %d", target_forward_count);
3475 increment_stats(stat_forward_count); 3508 increment_stats(stat_forward_count);
3476 GNUNET_free(stat_forward_count); 3509 GNUNET_free(stat_forward_count);
3477 if (msg_ctx->bloom == NULL) 3510 if (msg_ctx->bloom == NULL)
3478 msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); 3511 msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K);
3479 3512
3480 if ((stop_on_closest == GNUNET_YES) && (msg_ctx->closest == GNUNET_YES) && (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) 3513 if ((stop_on_closest == GNUNET_YES) && (msg_ctx->closest == GNUNET_YES) && (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT))
3481 forward_count = 0; 3514 target_forward_count = 0;
3482 3515
3483 /** 3516 /**
3484 * NOTICE: In Kademlia, a find peer request goes no further if the peer doesn't return 3517 * NOTICE: In Kademlia, a find peer request goes no further if the peer doesn't return
@@ -3496,22 +3529,8 @@ route_message(const struct GNUNET_MessageHeader *msg,
3496 * routing tables still get constructed. 3529 * routing tables still get constructed.
3497 */ 3530 */
3498 if ((GNUNET_YES == strict_kademlia) && (msg_ctx->closest == GNUNET_YES) && (msg_ctx->hop_count > 0) && (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) 3531 if ((GNUNET_YES == strict_kademlia) && (msg_ctx->closest == GNUNET_YES) && (msg_ctx->hop_count > 0) && (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER))
3499 forward_count = 0; 3532 target_forward_count = 0;
3500
3501#if DEBUG_DHT_ROUTING
3502 if (forward_count == 0)
3503 ret = GNUNET_SYSERR;
3504 else
3505 ret = GNUNET_NO;
3506 3533
3507 if ((debug_routes_extended) && (dhtlog_handle != NULL))
3508 {
3509 dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE,
3510 msg_ctx->hop_count, ret,
3511 &my_identity, &msg_ctx->key, msg_ctx->peer,
3512 NULL);
3513 }
3514#endif
3515 3534
3516 GNUNET_CONTAINER_bloomfilter_add (msg_ctx->bloom, &my_identity.hashPubKey); 3535 GNUNET_CONTAINER_bloomfilter_add (msg_ctx->bloom, &my_identity.hashPubKey);
3517 hash_from_uid (msg_ctx->unique_id, &unique_hash); 3536 hash_from_uid (msg_ctx->unique_id, &unique_hash);
@@ -3546,12 +3565,14 @@ route_message(const struct GNUNET_MessageHeader *msg,
3546 GNUNET_SCHEDULER_add_now(&remove_recent, recent_req); 3565 GNUNET_SCHEDULER_add_now(&remove_recent, recent_req);
3547 } 3566 }
3548 3567
3549 for (i = 0; i < forward_count; i++) 3568 forward_count = 0;
3569 for (i = 0; i < target_forward_count; i++)
3550 { 3570 {
3551 selected = select_peer(&msg_ctx->key, msg_ctx->bloom, msg_ctx->hop_count); 3571 selected = select_peer(&msg_ctx->key, msg_ctx->bloom, msg_ctx->hop_count);
3552 3572
3553 if (selected != NULL) 3573 if (selected != NULL)
3554 { 3574 {
3575 forward_count++;
3555 if (GNUNET_CRYPTO_hash_matching_bits(&selected->id.hashPubKey, &msg_ctx->key) >= GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &msg_ctx->key)) 3576 if (GNUNET_CRYPTO_hash_matching_bits(&selected->id.hashPubKey, &msg_ctx->key) >= GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &msg_ctx->key))
3556 GNUNET_asprintf(&temp_stat_str, "# requests routed to close(r) peer hop %u", msg_ctx->hop_count); 3577 GNUNET_asprintf(&temp_stat_str, "# requests routed to close(r) peer hop %u", msg_ctx->hop_count);
3557 else 3578 else
@@ -3589,6 +3610,21 @@ route_message(const struct GNUNET_MessageHeader *msg,
3589 GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom); 3610 GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom);
3590 msg_ctx->bloom = NULL; 3611 msg_ctx->bloom = NULL;
3591 } 3612 }
3613
3614#if DEBUG_DHT_ROUTING
3615 if (forward_count == 0)
3616 ret = GNUNET_SYSERR;
3617 else
3618 ret = GNUNET_NO;
3619
3620 if ((debug_routes_extended) && (dhtlog_handle != NULL))
3621 {
3622 dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE,
3623 msg_ctx->hop_count, ret,
3624 &my_identity, &msg_ctx->key, msg_ctx->peer,
3625 NULL);
3626 }
3627#endif
3592} 3628}
3593 3629
3594 3630
@@ -4243,14 +4279,6 @@ handle_dht_p2p_route_request (void *cls,
4243 struct GNUNET_MessageHeader *enc_msg = (struct GNUNET_MessageHeader *)&incoming[1]; 4279 struct GNUNET_MessageHeader *enc_msg = (struct GNUNET_MessageHeader *)&incoming[1];
4244 struct DHT_MessageContext *msg_ctx; 4280 struct DHT_MessageContext *msg_ctx;
4245 4281
4246 if (get_max_send_delay().rel_value > MAX_REQUEST_TIME.rel_value)
4247 {
4248 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending of previous replies took too long, backing off!\n");
4249 increment_stats("# route requests dropped due to high load");
4250 decrease_max_send_delay(get_max_send_delay());
4251 return GNUNET_YES;
4252 }
4253
4254 if (ntohs(enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_P2P_PING) /* Throw these away. FIXME: Don't throw these away? (reply)*/ 4282 if (ntohs(enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_P2P_PING) /* Throw these away. FIXME: Don't throw these away? (reply)*/
4255 { 4283 {
4256#if DEBUG_PING 4284#if DEBUG_PING
@@ -4264,6 +4292,24 @@ handle_dht_p2p_route_request (void *cls,
4264 GNUNET_break_op(0); 4292 GNUNET_break_op(0);
4265 return GNUNET_YES; 4293 return GNUNET_YES;
4266 } 4294 }
4295
4296 if (get_max_send_delay().rel_value > MAX_REQUEST_TIME.rel_value)
4297 {
4298 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending of previous replies took too long, backing off!\n");
4299 increment_stats("# route requests dropped due to high load");
4300 decrease_max_send_delay(get_max_send_delay());
4301#if DEBUG_DHT_ROUTING
4302 if ((debug_routes_extended) && (dhtlog_handle != NULL))
4303 {
4304 /** Log routes that die due to high load! */
4305 dhtlog_handle->insert_route (NULL, GNUNET_ntohll(incoming->unique_id), DHTLOG_ROUTE,
4306 ntohl(incoming->hop_count), GNUNET_SYSERR,
4307 &my_identity, &incoming->key, peer,
4308 NULL);
4309 }
4310#endif
4311 return GNUNET_YES;
4312 }
4267 msg_ctx = GNUNET_malloc(sizeof (struct DHT_MessageContext)); 4313 msg_ctx = GNUNET_malloc(sizeof (struct DHT_MessageContext));
4268 msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init(incoming->bloomfilter, DHT_BLOOM_SIZE, DHT_BLOOM_K); 4314 msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init(incoming->bloomfilter, DHT_BLOOM_SIZE, DHT_BLOOM_K);
4269 GNUNET_assert(msg_ctx->bloom != NULL); 4315 GNUNET_assert(msg_ctx->bloom != NULL);
@@ -4276,7 +4322,7 @@ handle_dht_p2p_route_request (void *cls,
4276 msg_ctx->peer = peer; 4322 msg_ctx->peer = peer;
4277 msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE; 4323 msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE;
4278 msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; 4324 msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT;
4279 demultiplex_message(enc_msg, msg_ctx); 4325 demultiplex_message (enc_msg, msg_ctx);
4280 if (msg_ctx->bloom != NULL) 4326 if (msg_ctx->bloom != NULL)
4281 { 4327 {
4282 GNUNET_CONTAINER_bloomfilter_free (msg_ctx->bloom); 4328 GNUNET_CONTAINER_bloomfilter_free (msg_ctx->bloom);