diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-16 18:48:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-16 18:48:00 +0000 |
commit | b896c07d2a8ab0c6a68423cfcf618fe0189050ee (patch) | |
tree | 854067e1133d319e68fe0967f4ba0c0ac6cbedbe /src/nse | |
parent | bed6f5700b1b08645184692a0eeeb6bee75e21e1 (diff) | |
download | gnunet-b896c07d2a8ab0c6a68423cfcf618fe0189050ee.tar.gz gnunet-b896c07d2a8ab0c6a68423cfcf618fe0189050ee.zip |
properly report NSE estimate to statistics (#3563?)
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 51874db14..b964b13c1 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -134,7 +134,7 @@ struct NSEPeerEntry | |||
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Did we receive or send a message about the previous round | 136 | * Did we receive or send a message about the previous round |
137 | * to this peer yet? GNUNET_YES if the previous round has | 137 | * to this peer yet? #GNUNET_YES if the previous round has |
138 | * been taken care of. | 138 | * been taken care of. |
139 | */ | 139 | */ |
140 | int previous_round; | 140 | int previous_round; |
@@ -171,7 +171,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
171 | struct GNUNET_NSE_FloodMessage | 171 | struct GNUNET_NSE_FloodMessage |
172 | { | 172 | { |
173 | /** | 173 | /** |
174 | * Type: GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD | 174 | * Type: #GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD |
175 | */ | 175 | */ |
176 | struct GNUNET_MessageHeader header; | 176 | struct GNUNET_MessageHeader header; |
177 | 177 | ||
@@ -399,11 +399,18 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) | |||
399 | em->reserved = htonl (0); | 399 | em->reserved = htonl (0); |
400 | em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | 400 | em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); |
401 | double se = mean - 0.332747; | 401 | double se = mean - 0.332747; |
402 | nsize = log2 (GNUNET_CONTAINER_multipeermap_size (peers) + 1); | 402 | j = GNUNET_CONTAINER_multipeermap_size (peers); |
403 | em->size_estimate = GNUNET_hton_double (GNUNET_MAX (se, nsize)); | 403 | if (0 == j) |
404 | j = 1; /* Avoid log2(0); can only happen if CORE didn't report | ||
405 | connection to self yet */ | ||
406 | nsize = log2 (j); | ||
407 | em->size_estimate = GNUNET_hton_double (GNUNET_MAX (se, | ||
408 | nsize)); | ||
404 | em->std_deviation = GNUNET_hton_double (std_dev); | 409 | em->std_deviation = GNUNET_hton_double (std_dev); |
405 | GNUNET_STATISTICS_set (stats, "# nodes in the network (estimate)", | 410 | GNUNET_STATISTICS_set (stats, |
406 | (uint64_t) pow (2, mean - 1.0 / 3.0), GNUNET_NO); | 411 | "# nodes in the network (estimate)", |
412 | (uint64_t) pow (2, em->size_estimate), | ||
413 | GNUNET_NO); | ||
407 | } | 414 | } |
408 | 415 | ||
409 | 416 | ||
@@ -519,10 +526,14 @@ get_matching_bits (struct GNUNET_TIME_Absolute timestamp, | |||
519 | struct GNUNET_HashCode timestamp_hash; | 526 | struct GNUNET_HashCode timestamp_hash; |
520 | struct GNUNET_HashCode pid_hash; | 527 | struct GNUNET_HashCode pid_hash; |
521 | 528 | ||
522 | GNUNET_CRYPTO_hash (×tamp.abs_value_us, sizeof (timestamp.abs_value_us), | 529 | GNUNET_CRYPTO_hash (×tamp.abs_value_us, |
530 | sizeof (timestamp.abs_value_us), | ||
523 | ×tamp_hash); | 531 | ×tamp_hash); |
524 | GNUNET_CRYPTO_hash (id, sizeof (struct GNUNET_PeerIdentity), &pid_hash); | 532 | GNUNET_CRYPTO_hash (id, |
525 | return GNUNET_CRYPTO_hash_matching_bits (×tamp_hash, &pid_hash); | 533 | sizeof (struct GNUNET_PeerIdentity), |
534 | &pid_hash); | ||
535 | return GNUNET_CRYPTO_hash_matching_bits (×tamp_hash, | ||
536 | &pid_hash); | ||
526 | } | 537 | } |
527 | 538 | ||
528 | 539 | ||
@@ -618,8 +629,9 @@ transmit_ready (void *cls, | |||
618 | idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE; | 629 | idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE; |
619 | peer_entry->previous_round = GNUNET_YES; | 630 | peer_entry->previous_round = GNUNET_YES; |
620 | peer_entry->transmit_task = | 631 | peer_entry->transmit_task = |
621 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (0), &transmit_task_cb, | 632 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (0), |
622 | peer_entry); | 633 | &transmit_task_cb, |
634 | peer_entry); | ||
623 | } | 635 | } |
624 | if ((0 == ntohl (size_estimate_messages[idx].hop_count)) && | 636 | if ((0 == ntohl (size_estimate_messages[idx].hop_count)) && |
625 | (GNUNET_SCHEDULER_NO_TASK != proof_task)) | 637 | (GNUNET_SCHEDULER_NO_TASK != proof_task)) |
@@ -827,7 +839,9 @@ update_flood_message (void *cls, | |||
827 | for (i = 0; i < HISTORY_SIZE; i++) | 839 | for (i = 0; i < HISTORY_SIZE; i++) |
828 | hop_count_max = | 840 | hop_count_max = |
829 | GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max); | 841 | GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max); |
830 | GNUNET_CONTAINER_multipeermap_iterate (peers, &schedule_current_round, NULL); | 842 | GNUNET_CONTAINER_multipeermap_iterate (peers, |
843 | &schedule_current_round, | ||
844 | NULL); | ||
831 | flood_task = | 845 | flood_task = |
832 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 846 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
833 | (next_timestamp), &update_flood_message, | 847 | (next_timestamp), &update_flood_message, |
@@ -1229,7 +1243,6 @@ handle_p2p_size_estimate (void *cls, | |||
1229 | } | 1243 | } |
1230 | 1244 | ||
1231 | 1245 | ||
1232 | |||
1233 | /** | 1246 | /** |
1234 | * Method called whenever a peer connects. Sets up the PeerEntry and | 1247 | * Method called whenever a peer connects. Sets up the PeerEntry and |
1235 | * schedules the initial size info transmission to this peer. | 1248 | * schedules the initial size info transmission to this peer. |
@@ -1243,18 +1256,24 @@ handle_core_connect (void *cls, | |||
1243 | { | 1256 | { |
1244 | struct NSEPeerEntry *peer_entry; | 1257 | struct NSEPeerEntry *peer_entry; |
1245 | 1258 | ||
1246 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected to us\n", | 1259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1260 | "Peer `%s' connected to us\n", | ||
1247 | GNUNET_i2s (peer)); | 1261 | GNUNET_i2s (peer)); |
1248 | peer_entry = GNUNET_new (struct NSEPeerEntry); | 1262 | peer_entry = GNUNET_new (struct NSEPeerEntry); |
1249 | peer_entry->id = *peer; | 1263 | peer_entry->id = *peer; |
1250 | GNUNET_assert (GNUNET_OK == | 1264 | GNUNET_assert (GNUNET_OK == |
1251 | GNUNET_CONTAINER_multipeermap_put (peers, peer, | 1265 | GNUNET_CONTAINER_multipeermap_put (peers, |
1266 | peer, | ||
1252 | peer_entry, | 1267 | peer_entry, |
1253 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1268 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1254 | peer_entry->transmit_task = | 1269 | peer_entry->transmit_task = |
1255 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task_cb, | 1270 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), |
1271 | &transmit_task_cb, | ||
1256 | peer_entry); | 1272 | peer_entry); |
1257 | GNUNET_STATISTICS_update (stats, "# peers connected", 1, GNUNET_NO); | 1273 | GNUNET_STATISTICS_update (stats, |
1274 | "# peers connected", | ||
1275 | 1, | ||
1276 | GNUNET_NO); | ||
1258 | } | 1277 | } |
1259 | 1278 | ||
1260 | 1279 | ||
@@ -1540,7 +1559,7 @@ run (void *cls, | |||
1540 | GNUNET_CLIENT_service_test ("testbed-logger", cfg, | 1559 | GNUNET_CLIENT_service_test ("testbed-logger", cfg, |
1541 | GNUNET_TIME_UNIT_SECONDS, | 1560 | GNUNET_TIME_UNIT_SECONDS, |
1542 | &status_cb, NULL); | 1561 | &status_cb, NULL); |
1543 | 1562 | ||
1544 | } | 1563 | } |
1545 | #endif | 1564 | #endif |
1546 | 1565 | ||