diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-23 17:48:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-23 17:48:48 +0000 |
commit | e5e33fe06042fe6c90f0a755a5c41f8f730c387c (patch) | |
tree | 8ba7b5f7e2c287ace81ae92a1c5e04db48184864 /src/nse | |
parent | 49fb611b2c5c7e438318356a675d8da99e52d739 (diff) | |
download | gnunet-e5e33fe06042fe6c90f0a755a5c41f8f730c387c.tar.gz gnunet-e5e33fe06042fe6c90f0a755a5c41f8f730c387c.zip |
fix starting stddevs/avgs
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 20 | ||||
-rw-r--r-- | src/nse/test_nse.conf | 2 | ||||
-rw-r--r-- | src/nse/test_nse_multipeer.c | 4 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index cb0216dc6..1d5421acb 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -72,7 +72,7 @@ | |||
72 | /** | 72 | /** |
73 | * Interval for sending network size estimation flood requests. | 73 | * Interval for sending network size estimation flood requests. |
74 | */ | 74 | */ |
75 | #define GNUNET_NSE_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | 75 | #define GNUNET_NSE_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) |
76 | 76 | ||
77 | 77 | ||
78 | /** | 78 | /** |
@@ -209,6 +209,11 @@ static struct GNUNET_NSE_FloodMessage size_estimate_messages[HISTORY_SIZE]; | |||
209 | static unsigned int estimate_index; | 209 | static unsigned int estimate_index; |
210 | 210 | ||
211 | /** | 211 | /** |
212 | * Number of valid entries in the history. | ||
213 | */ | ||
214 | static unsigned int estimate_count; | ||
215 | |||
216 | /** | ||
212 | * Task scheduled to update our flood message for the next round. | 217 | * Task scheduled to update our flood message for the next round. |
213 | */ | 218 | */ |
214 | static GNUNET_SCHEDULER_TaskIdentifier flood_task; | 219 | static GNUNET_SCHEDULER_TaskIdentifier flood_task; |
@@ -274,10 +279,10 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) | |||
274 | mean = 0.0; | 279 | mean = 0.0; |
275 | sum = 0.0; | 280 | sum = 0.0; |
276 | sumweight = 0.0; | 281 | sumweight = 0.0; |
277 | for (i=0; i<HISTORY_SIZE; i++) | 282 | for (i=0;i<estimate_count; i++) |
278 | { | 283 | { |
279 | val = htonl (size_estimate_messages[i].matching_bits); | 284 | val = htonl (size_estimate_messages[(estimate_index - i + HISTORY_SIZE) % HISTORY_SIZE].matching_bits); |
280 | weight = HISTORY_SIZE - ((estimate_index + HISTORY_SIZE - i) % HISTORY_SIZE); | 285 | weight = estimate_count + 1 - i; |
281 | 286 | ||
282 | temp = weight + sumweight; | 287 | temp = weight + sumweight; |
283 | q = val - mean; | 288 | q = val - mean; |
@@ -300,7 +305,7 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) | |||
300 | em->size_estimate = mean - 0.5; | 305 | em->size_estimate = mean - 0.5; |
301 | em->std_deviation = std_dev; | 306 | em->std_deviation = std_dev; |
302 | GNUNET_STATISTICS_set (stats, | 307 | GNUNET_STATISTICS_set (stats, |
303 | "Current network size estimate", | 308 | "# nodes in the network (estimate)", |
304 | (uint64_t) pow (2, mean - 0.5), GNUNET_NO); | 309 | (uint64_t) pow (2, mean - 0.5), GNUNET_NO); |
305 | } | 310 | } |
306 | 311 | ||
@@ -625,6 +630,8 @@ update_flood_message(void *cls, | |||
625 | next_timestamp = GNUNET_TIME_absolute_add (current_timestamp, | 630 | next_timestamp = GNUNET_TIME_absolute_add (current_timestamp, |
626 | GNUNET_NSE_INTERVAL); | 631 | GNUNET_NSE_INTERVAL); |
627 | estimate_index = (estimate_index + 1) % HISTORY_SIZE; | 632 | estimate_index = (estimate_index + 1) % HISTORY_SIZE; |
633 | if (estimate_count < HISTORY_SIZE) | ||
634 | estimate_count++; | ||
628 | setup_flood_message (estimate_index, current_timestamp); | 635 | setup_flood_message (estimate_index, current_timestamp); |
629 | hop_count_max = 0; | 636 | hop_count_max = 0; |
630 | for (i=0;i<HISTORY_SIZE;i++) | 637 | for (i=0;i<HISTORY_SIZE;i++) |
@@ -1051,6 +1058,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
1051 | setup_flood_message (i, prev_time); | 1058 | setup_flood_message (i, prev_time); |
1052 | } | 1059 | } |
1053 | estimate_index = HISTORY_SIZE - 1; | 1060 | estimate_index = HISTORY_SIZE - 1; |
1061 | estimate_count = 2; | ||
1054 | flood_task | 1062 | flood_task |
1055 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (next_timestamp), | 1063 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (next_timestamp), |
1056 | &update_flood_message, NULL); | 1064 | &update_flood_message, NULL); |
@@ -1124,7 +1132,7 @@ run(void *cls, struct GNUNET_SERVER_Handle *server, | |||
1124 | GNUNET_SCHEDULER_shutdown (); | 1132 | GNUNET_SCHEDULER_shutdown (); |
1125 | return; | 1133 | return; |
1126 | } | 1134 | } |
1127 | stats = GNUNET_STATISTICS_create ("NSE", cfg); | 1135 | stats = GNUNET_STATISTICS_create ("nse", cfg); |
1128 | } | 1136 | } |
1129 | 1137 | ||
1130 | 1138 | ||
diff --git a/src/nse/test_nse.conf b/src/nse/test_nse.conf index 17574a748..abd623687 100644 --- a/src/nse/test_nse.conf +++ b/src/nse/test_nse.conf | |||
@@ -40,7 +40,7 @@ AUTOSTART = YES | |||
40 | AUTOSTART = NO | 40 | AUTOSTART = NO |
41 | 41 | ||
42 | [testing] | 42 | [testing] |
43 | NUM_PEERS = 20 | 43 | NUM_PEERS = 1000 |
44 | WEAKRANDOM = YES | 44 | WEAKRANDOM = YES |
45 | TOPOLOGY = NONE | 45 | TOPOLOGY = NONE |
46 | CONNECT_TOPOLOGY = SMALL_WORLD_RING | 46 | CONNECT_TOPOLOGY = SMALL_WORLD_RING |
diff --git a/src/nse/test_nse_multipeer.c b/src/nse/test_nse_multipeer.c index bfd7741b1..c277fdf7b 100644 --- a/src/nse/test_nse_multipeer.c +++ b/src/nse/test_nse_multipeer.c | |||
@@ -49,9 +49,9 @@ struct NSEPeer *peer_head; | |||
49 | struct NSEPeer *peer_tail; | 49 | struct NSEPeer *peer_tail; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * How long until we give up on connecting the peers? | 52 | * How long do we run the test? |
53 | */ | 53 | */ |
54 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500) | 54 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
55 | 55 | ||
56 | static int ok; | 56 | static int ok; |
57 | 57 | ||