aboutsummaryrefslogtreecommitdiff
path: root/src/nse
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-23 21:06:27 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-23 21:06:27 +0000
commit9761be954b27ef3ba33d39c1576535af8a7e00b6 (patch)
treeba86bb67ddf12ef980762f44bd5ccbf41b829e69 /src/nse
parent3137ebd45e94b3555cc5c1c37d1ee6b980568886 (diff)
downloadgnunet-9761be954b27ef3ba33d39c1576535af8a7e00b6.tar.gz
gnunet-9761be954b27ef3ba33d39c1576535af8a7e00b6.zip
success
Diffstat (limited to 'src/nse')
-rw-r--r--src/nse/gnunet-service-nse.c48
-rw-r--r--src/nse/nse.h2
-rw-r--r--src/nse/test_nse.conf2
3 files changed, 32 insertions, 20 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index 2e7a7248d..ad7a0bef1 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -45,8 +45,6 @@
45#include "gnunet_nse_service.h" 45#include "gnunet_nse_service.h"
46#include "nse.h" 46#include "nse.h"
47 47
48#define DEBUG_NSE GNUNET_YES
49
50/** 48/**
51 * Over how many values do we calculate the weighted average? 49 * Over how many values do we calculate the weighted average?
52 */ 50 */
@@ -106,7 +104,8 @@ struct NSEPeerEntry
106 104
107 /** 105 /**
108 * Did we receive or send a message about the previous round 106 * Did we receive or send a message about the previous round
109 * to this peer yet? 107 * to this peer yet? GNUNET_YES if the previous round has
108 * been taken care of.
110 */ 109 */
111 int previous_round; 110 int previous_round;
112}; 111};
@@ -338,6 +337,7 @@ handle_start_message(void *cls, struct GNUNET_SERVER_Client *client,
338 const struct GNUNET_MessageHeader *message) 337 const struct GNUNET_MessageHeader *message)
339{ 338{
340 struct GNUNET_NSE_ClientMessage em; 339 struct GNUNET_NSE_ClientMessage em;
340
341#if DEBUG_NSE 341#if DEBUG_NSE
342 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 342 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
343 "Received START message from client\n"); 343 "Received START message from client\n");
@@ -364,7 +364,7 @@ get_matching_bits_delay (uint32_t matching_bits)
364 // x is matching_bits 364 // x is matching_bits
365 // p' is current_size_estimate 365 // p' is current_size_estimate
366 return ((double) GNUNET_NSE_INTERVAL.rel_value / (double) 2.0) 366 return ((double) GNUNET_NSE_INTERVAL.rel_value / (double) 2.0)
367 - ((GNUNET_NSE_INTERVAL.rel_value / M_PI) * atan (current_size_estimate - matching_bits)); 367 - ((GNUNET_NSE_INTERVAL.rel_value / M_PI) * atan (matching_bits - current_size_estimate));
368} 368}
369 369
370 370
@@ -430,6 +430,11 @@ get_transmit_delay (int round_offset)
430 /* previous round is randomized between 0 and 50 ms */ 430 /* previous round is randomized between 0 and 50 ms */
431 ret.rel_value = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 431 ret.rel_value = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
432 50); 432 50);
433#if DEBUG_NSE
434 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
435 "Transmitting previous round behind schedule in %llu ms\n",
436 (unsigned long long) ret.rel_value);
437#endif
433 return ret; 438 return ret;
434 case 0: 439 case 0:
435 /* current round is based on best-known matching_bits */ 440 /* current round is based on best-known matching_bits */
@@ -437,6 +442,13 @@ get_transmit_delay (int round_offset)
437 dist_delay = get_matching_bits_delay (matching_bits); 442 dist_delay = get_matching_bits_delay (matching_bits);
438 dist_delay += get_delay_randomization (matching_bits).rel_value; 443 dist_delay += get_delay_randomization (matching_bits).rel_value;
439 ret.rel_value = (uint64_t) dist_delay; 444 ret.rel_value = (uint64_t) dist_delay;
445#if DEBUG_NSE
446 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
447 "For round %llu, delay for %u matching bits is %llu ms\n",
448 (unsigned long long) current_timestamp.abs_value,
449 (unsigned int) matching_bits,
450 (unsigned long long) ret.rel_value);
451#endif
440 /* now consider round start time and add delay to it */ 452 /* now consider round start time and add delay to it */
441 tgt = GNUNET_TIME_absolute_add (current_timestamp, ret); 453 tgt = GNUNET_TIME_absolute_add (current_timestamp, ret);
442 return GNUNET_TIME_absolute_get_remaining (tgt); 454 return GNUNET_TIME_absolute_get_remaining (tgt);
@@ -479,16 +491,11 @@ transmit_ready (void *cls, size_t size, void *buf)
479 return 0; 491 return 0;
480 } 492 }
481 GNUNET_assert (size >= sizeof (struct GNUNET_NSE_FloodMessage)); 493 GNUNET_assert (size >= sizeof (struct GNUNET_NSE_FloodMessage));
482#if DEBUG_NSE > 1
483 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
484 "Sending size estimate to `%s'\n",
485 GNUNET_i2s (&peer_entry->id));
486#endif
487 idx = estimate_index; 494 idx = estimate_index;
488 if (peer_entry->previous_round == GNUNET_YES) 495 if (peer_entry->previous_round == GNUNET_NO)
489 { 496 {
490 idx = (idx + HISTORY_SIZE -1) % HISTORY_SIZE; 497 idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE;
491 peer_entry->previous_round = GNUNET_NO; 498 peer_entry->previous_round = GNUNET_YES;
492 peer_entry->transmit_task = GNUNET_SCHEDULER_add_delayed (get_transmit_delay (0), 499 peer_entry->transmit_task = GNUNET_SCHEDULER_add_delayed (get_transmit_delay (0),
493 &transmit_task, 500 &transmit_task,
494 peer_entry); 501 peer_entry);
@@ -502,6 +509,13 @@ transmit_ready (void *cls, size_t size, void *buf)
502 GNUNET_NO); 509 GNUNET_NO);
503 return 0; 510 return 0;
504 } 511 }
512#if DEBUG_NSE
513 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
514 "In round %llu, sending to `%s' estimate with %u bits\n",
515 (unsigned long long) GNUNET_TIME_absolute_ntoh (size_estimate_messages[idx].timestamp).abs_value,
516 GNUNET_i2s (&peer_entry->id),
517 (unsigned int) ntohl (size_estimate_messages[idx].matching_bits));
518#endif
505 if (ntohl (size_estimate_messages[idx].hop_count) == 0) 519 if (ntohl (size_estimate_messages[idx].hop_count) == 0)
506 GNUNET_STATISTICS_update (stats, 520 GNUNET_STATISTICS_update (stats,
507 "# flood messages started", 521 "# flood messages started",
@@ -884,7 +898,7 @@ update_flood_times (void *cls,
884 return GNUNET_OK; /* already active */ 898 return GNUNET_OK; /* already active */
885 if (peer_entry == exclude) 899 if (peer_entry == exclude)
886 return GNUNET_OK; /* trigger of the update */ 900 return GNUNET_OK; /* trigger of the update */
887 if (peer_entry->previous_round == GNUNET_YES) 901 if (peer_entry->previous_round == GNUNET_NO)
888 { 902 {
889 /* still stuck in previous round, no point to update, check that 903 /* still stuck in previous round, no point to update, check that
890 we are active here though... */ 904 we are active here though... */
@@ -1003,14 +1017,13 @@ handle_p2p_size_estimate(void *cls,
1003 /* cancel transmission from us to this peer for this round */ 1017 /* cancel transmission from us to this peer for this round */
1004 if (idx == estimate_index) 1018 if (idx == estimate_index)
1005 { 1019 {
1006 if (peer_entry->previous_round == GNUNET_NO) 1020 if (peer_entry->previous_round == GNUNET_YES)
1007 { 1021 {
1008 /* cancel any activity for current round */ 1022 /* cancel any activity for current round */
1009 if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) 1023 if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
1010 { 1024 {
1011 GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); 1025 GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
1012 peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; 1026 peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK;
1013 peer_entry->previous_round = GNUNET_NO;
1014 } 1027 }
1015 if (peer_entry->th != NULL) 1028 if (peer_entry->th != NULL)
1016 { 1029 {
@@ -1022,9 +1035,8 @@ handle_p2p_size_estimate(void *cls,
1022 else 1035 else
1023 { 1036 {
1024 /* cancel previous round only */ 1037 /* cancel previous round only */
1025 peer_entry->previous_round = GNUNET_NO; 1038 peer_entry->previous_round = GNUNET_YES;
1026 } 1039 }
1027
1028 } 1040 }
1029 if (matching_bits <= ntohl (size_estimate_messages[idx].matching_bits)) 1041 if (matching_bits <= ntohl (size_estimate_messages[idx].matching_bits))
1030 { 1042 {
diff --git a/src/nse/nse.h b/src/nse/nse.h
index 9a13d99b2..24001e8cc 100644
--- a/src/nse/nse.h
+++ b/src/nse/nse.h
@@ -30,7 +30,7 @@
30 30
31#include "gnunet_common.h" 31#include "gnunet_common.h"
32 32
33#define DEBUG_NSE GNUNET_YES 33#define DEBUG_NSE GNUNET_NO
34 34
35#define VERIFY_CRYPTO GNUNET_NO 35#define VERIFY_CRYPTO GNUNET_NO
36 36
diff --git a/src/nse/test_nse.conf b/src/nse/test_nse.conf
index e8e612d45..ee3c208a2 100644
--- a/src/nse/test_nse.conf
+++ b/src/nse/test_nse.conf
@@ -49,7 +49,7 @@ EXTERNAL_ADDRESS = 127.0.0.1
49AUTOSTART = NO 49AUTOSTART = NO
50 50
51[testing] 51[testing]
52NUM_PEERS = 10 52NUM_PEERS = 100
53WEAKRANDOM = YES 53WEAKRANDOM = YES
54TOPOLOGY = NONE 54TOPOLOGY = NONE
55CONNECT_TOPOLOGY = SMALL_WORLD_RING 55CONNECT_TOPOLOGY = SMALL_WORLD_RING