diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-12-21 18:03:30 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-12-21 18:03:30 +0000 |
commit | 49c4c6aea3a3c00fa8a7649e2abbc82a579d10a9 (patch) | |
tree | cfbcc4a57a772714e8292c09c4e4fafbb2499a30 /src/nse | |
parent | 5eddc3e06cc947cd605aec8c65ce16770d79b64e (diff) | |
download | gnunet-49c4c6aea3a3c00fa8a7649e2abbc82a579d10a9.tar.gz gnunet-49c4c6aea3a3c00fa8a7649e2abbc82a579d10a9.zip |
Added statistic reading to NSE, fixed some minor bugs
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-nse-profiler.c | 56 | ||||
-rw-r--r-- | src/nse/gnunet-service-nse.c | 107 |
2 files changed, 120 insertions, 43 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index cf61d7ee8..801063b23 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -58,10 +58,21 @@ struct StatsContext | |||
58 | * How many messages have peers received during the test. | 58 | * How many messages have peers received during the test. |
59 | */ | 59 | */ |
60 | unsigned long long total_nse_received_messages; | 60 | unsigned long long total_nse_received_messages; |
61 | |||
61 | /** | 62 | /** |
62 | * How many messages have peers send during the test (should be == received). | 63 | * How many messages have peers send during the test (should be == received). |
63 | */ | 64 | */ |
64 | unsigned long long total_nse_sent_messages; | 65 | unsigned long long total_nse_transmitted_messages; |
66 | |||
67 | /** | ||
68 | * How many messages have travelled an edge in both directions. | ||
69 | */ | ||
70 | unsigned long long total_nse_cross; | ||
71 | |||
72 | /** | ||
73 | * How many extra messages per edge (corrections) have been received. | ||
74 | */ | ||
75 | unsigned long long total_nse_extra; | ||
65 | }; | 76 | }; |
66 | 77 | ||
67 | 78 | ||
@@ -410,16 +421,40 @@ stats_finished_callback (void *cls, int success) | |||
410 | GNUNET_DISK_file_write (data_file, buf, buf_len); | 421 | GNUNET_DISK_file_write (data_file, buf, buf_len); |
411 | } | 422 | } |
412 | GNUNET_free_non_null (buf); | 423 | GNUNET_free_non_null (buf); |
424 | |||
413 | buf = NULL; | 425 | buf = NULL; |
414 | buf_len = | 426 | buf_len = |
415 | GNUNET_asprintf (&buf, "TOTAL_NSE_SENT_MESSAGES_%d: %u\n", | 427 | GNUNET_asprintf (&buf, "TOTAL_NSE_TRANSMITTED_MESSAGES_%d: %u\n", |
416 | stats_context->shutdown, | 428 | stats_context->shutdown, |
417 | stats_context->total_nse_received_messages); | 429 | stats_context->total_nse_transmitted_messages); |
430 | if (buf_len > 0) | ||
431 | { | ||
432 | GNUNET_DISK_file_write (data_file, buf, buf_len); | ||
433 | } | ||
434 | GNUNET_free_non_null (buf); | ||
435 | |||
436 | buf = NULL; | ||
437 | buf_len = | ||
438 | GNUNET_asprintf (&buf, "TOTAL_NSE_CROSS_%d: %u \n", | ||
439 | stats_context->shutdown, | ||
440 | stats_context->total_nse_cross); | ||
441 | if (buf_len > 0) | ||
442 | { | ||
443 | GNUNET_DISK_file_write (data_file, buf, buf_len); | ||
444 | } | ||
445 | GNUNET_free_non_null (buf); | ||
446 | |||
447 | buf = NULL; | ||
448 | buf_len = | ||
449 | GNUNET_asprintf (&buf, "TOTAL_NSE_EXTRA_%d: %u \n", | ||
450 | stats_context->shutdown, | ||
451 | stats_context->total_nse_extra); | ||
418 | if (buf_len > 0) | 452 | if (buf_len > 0) |
419 | { | 453 | { |
420 | GNUNET_DISK_file_write (data_file, buf, buf_len); | 454 | GNUNET_DISK_file_write (data_file, buf, buf_len); |
421 | } | 455 | } |
422 | GNUNET_free_non_null (buf); | 456 | GNUNET_free_non_null (buf); |
457 | |||
423 | } | 458 | } |
424 | 459 | ||
425 | if (GNUNET_YES == stats_context->shutdown) | 460 | if (GNUNET_YES == stats_context->shutdown) |
@@ -476,9 +511,9 @@ statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
476 | } | 511 | } |
477 | #endif | 512 | #endif |
478 | } | 513 | } |
479 | if (0 == strcmp (name, "# flood messages sent")) | 514 | if (0 == strcmp (name, "# flood messages transmitted")) |
480 | { | 515 | { |
481 | stats_context->total_nse_sent_messages += value; | 516 | stats_context->total_nse_transmitted_messages += value; |
482 | #if VERBOSE | 517 | #if VERBOSE |
483 | if (data_file != NULL) | 518 | if (data_file != NULL) |
484 | { | 519 | { |
@@ -487,7 +522,8 @@ statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
487 | 522 | ||
488 | buf = NULL; | 523 | buf = NULL; |
489 | buf_len = | 524 | buf_len = |
490 | GNUNET_asprintf (&buf, "%s %u SENT\n", GNUNET_i2s(peer), value); | 525 | GNUNET_asprintf (&buf, "%s %u TRANSMITTED\n", |
526 | GNUNET_i2s(peer), value); | ||
491 | if (buf_len > 0) | 527 | if (buf_len > 0) |
492 | { | 528 | { |
493 | GNUNET_DISK_file_write (data_file, buf, buf_len); | 529 | GNUNET_DISK_file_write (data_file, buf, buf_len); |
@@ -496,6 +532,14 @@ statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
496 | } | 532 | } |
497 | #endif | 533 | #endif |
498 | } | 534 | } |
535 | if (0 == strcmp (name, "# cross messages")) | ||
536 | { | ||
537 | stats_context->total_nse_cross += value; | ||
538 | } | ||
539 | if (0 == strcmp (name, "# extra messages")) | ||
540 | { | ||
541 | stats_context->total_nse_extra += value; | ||
542 | } | ||
499 | } | 543 | } |
500 | return GNUNET_OK; | 544 | return GNUNET_OK; |
501 | } | 545 | } |
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index d37ecd941..30493851e 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -125,6 +125,26 @@ struct NSEPeerEntry | |||
125 | * been taken care of. | 125 | * been taken care of. |
126 | */ | 126 | */ |
127 | int previous_round; | 127 | int previous_round; |
128 | |||
129 | #if ENABLE_HISTOGRAM | ||
130 | |||
131 | /** | ||
132 | * Amount of messages received from this peer on this round. | ||
133 | */ | ||
134 | unsigned int received_messages; | ||
135 | |||
136 | /** | ||
137 | * Amount of messages transmitted to this peer on this round. | ||
138 | */ | ||
139 | unsigned int transmitted_messages; | ||
140 | |||
141 | /** | ||
142 | * Which size did we tell the peer the network is? | ||
143 | */ | ||
144 | unsigned int last_transmitted_size; | ||
145 | |||
146 | #endif | ||
147 | |||
128 | }; | 148 | }; |
129 | 149 | ||
130 | 150 | ||
@@ -593,6 +613,11 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
593 | GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO); | 613 | GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO); |
594 | GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1, | 614 | GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1, |
595 | GNUNET_NO); | 615 | GNUNET_NO); |
616 | #if ENABLE_HISTOGRAM | ||
617 | peer_entry->transmitted_messages++; | ||
618 | peer_entry->last_transmitted_size = | ||
619 | ntohl(size_estimate_messages[idx].matching_bits); | ||
620 | #endif | ||
596 | memcpy (buf, &size_estimate_messages[idx], | 621 | memcpy (buf, &size_estimate_messages[idx], |
597 | sizeof (struct GNUNET_NSE_FloodMessage)); | 622 | sizeof (struct GNUNET_NSE_FloodMessage)); |
598 | return sizeof (struct GNUNET_NSE_FloodMessage); | 623 | return sizeof (struct GNUNET_NSE_FloodMessage); |
@@ -699,6 +724,14 @@ schedule_current_round (void *cls, const GNUNET_HashCode * key, void *value) | |||
699 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 724 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
700 | peer_entry->previous_round = GNUNET_NO; | 725 | peer_entry->previous_round = GNUNET_NO; |
701 | } | 726 | } |
727 | #if ENABLE_HISTOGRAM | ||
728 | if (peer_entry->received_messages > 1) | ||
729 | GNUNET_STATISTICS_update(stats, "# extra messages", | ||
730 | peer_entry->received_messages - 1, GNUNET_NO); | ||
731 | peer_entry->transmitted_messages = 0; | ||
732 | peer_entry->last_transmitted_size = 0; | ||
733 | peer_entry->received_messages = 0; | ||
734 | #endif | ||
702 | delay = | 735 | delay = |
703 | get_transmit_delay ((peer_entry->previous_round == GNUNET_NO) ? -1 : 0); | 736 | get_transmit_delay ((peer_entry->previous_round == GNUNET_NO) ? -1 : 0); |
704 | peer_entry->transmit_task = | 737 | peer_entry->transmit_task = |
@@ -1012,6 +1045,12 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1012 | GNUNET_break (0); | 1045 | GNUNET_break (0); |
1013 | return GNUNET_OK; | 1046 | return GNUNET_OK; |
1014 | } | 1047 | } |
1048 | #if ENABLE_HISTOGRAM | ||
1049 | peer_entry->received_messages++; | ||
1050 | if (peer_entry->transmitted_messages > 0 && | ||
1051 | peer_entry->last_transmitted_size >= matching_bits) | ||
1052 | GNUNET_STATISTICS_update(stats, "# cross messages", 1, GNUNET_NO); | ||
1053 | #endif | ||
1015 | 1054 | ||
1016 | ts = GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp); | 1055 | ts = GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp); |
1017 | 1056 | ||
@@ -1048,48 +1087,21 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1048 | update_network_size_estimate (); | 1087 | update_network_size_estimate (); |
1049 | return GNUNET_OK; | 1088 | return GNUNET_OK; |
1050 | } | 1089 | } |
1051 | if (matching_bits >= ntohl (size_estimate_messages[idx].matching_bits)) | ||
1052 | { | ||
1053 | /* cancel transmission from us to this peer for this round */ | ||
1054 | if (idx == estimate_index) | ||
1055 | { | ||
1056 | if (peer_entry->previous_round == GNUNET_YES) | ||
1057 | { | ||
1058 | /* cancel any activity for current round */ | ||
1059 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) | ||
1060 | { | ||
1061 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | ||
1062 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; | ||
1063 | } | ||
1064 | if (peer_entry->th != NULL) | ||
1065 | { | ||
1066 | GNUNET_CORE_notify_transmit_ready_cancel (peer_entry->th); | ||
1067 | peer_entry->th = NULL; | ||
1068 | } | ||
1069 | } | ||
1070 | } | ||
1071 | else | ||
1072 | { | ||
1073 | /* cancel previous round only */ | ||
1074 | peer_entry->previous_round = GNUNET_YES; | ||
1075 | } | ||
1076 | } | ||
1077 | if (matching_bits == ntohl (size_estimate_messages[idx].matching_bits)) | 1090 | if (matching_bits == ntohl (size_estimate_messages[idx].matching_bits)) |
1078 | { | 1091 | { |
1079 | /* cancel transmission in the other direction, as this peer clearly has | 1092 | /* Cancel transmission in the other direction, as this peer clearly has |
1080 | up-to-date information already */ | 1093 | up-to-date information already. Even if we didn't talk to this peer in |
1094 | the previous round, we should no longer send it stale information as it | ||
1095 | told us about the current round! */ | ||
1096 | peer_entry->previous_round = GNUNET_YES; | ||
1081 | if (idx != estimate_index) | 1097 | if (idx != estimate_index) |
1082 | { | 1098 | { |
1083 | /* do not transmit information for the previous round to this peer | 1099 | /* do not transmit information for the previous round to this peer |
1084 | anymore (but allow current round) */ | 1100 | anymore (but allow current round) */ |
1085 | peer_entry->previous_round = GNUNET_YES; | ||
1086 | return GNUNET_OK; | 1101 | return GNUNET_OK; |
1087 | } | 1102 | } |
1088 | /* even if we didn't talk to this peer in the previous round, we should | 1103 | /* got up-to-date information for current round, cancel transmission to |
1089 | no longer send it stale information as it told us about the current | 1104 | * this peer altogether */ |
1090 | round! */ | ||
1091 | peer_entry->previous_round = GNUNET_YES; | ||
1092 | /* got up-to-date information for current round, cancel transmission altogether */ | ||
1093 | if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task) | 1105 | if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task) |
1094 | { | 1106 | { |
1095 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 1107 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
@@ -1102,7 +1114,7 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1102 | } | 1114 | } |
1103 | return GNUNET_OK; | 1115 | return GNUNET_OK; |
1104 | } | 1116 | } |
1105 | if (matching_bits <= ntohl (size_estimate_messages[idx].matching_bits)) | 1117 | if (matching_bits < ntohl (size_estimate_messages[idx].matching_bits)) |
1106 | { | 1118 | { |
1107 | if ((idx < estimate_index) && (peer_entry->previous_round == GNUNET_YES)) | 1119 | if ((idx < estimate_index) && (peer_entry->previous_round == GNUNET_YES)) |
1108 | peer_entry->previous_round = GNUNET_NO; | 1120 | peer_entry->previous_round = GNUNET_NO; |
@@ -1125,6 +1137,28 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1125 | GNUNET_break_op (0); | 1137 | GNUNET_break_op (0); |
1126 | return GNUNET_OK; | 1138 | return GNUNET_OK; |
1127 | } | 1139 | } |
1140 | GNUNET_assert (matching_bits > | ||
1141 | ntohl (size_estimate_messages[idx].matching_bits)); | ||
1142 | /* cancel transmission from us to this peer for this round */ | ||
1143 | if (idx == estimate_index) | ||
1144 | { | ||
1145 | /* cancel any activity for current round */ | ||
1146 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) | ||
1147 | { | ||
1148 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | ||
1149 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; | ||
1150 | } | ||
1151 | if (peer_entry->th != NULL) | ||
1152 | { | ||
1153 | GNUNET_CORE_notify_transmit_ready_cancel (peer_entry->th); | ||
1154 | peer_entry->th = NULL; | ||
1155 | } | ||
1156 | } | ||
1157 | else | ||
1158 | { | ||
1159 | /* cancel previous round only */ | ||
1160 | peer_entry->previous_round = GNUNET_YES; | ||
1161 | } | ||
1128 | size_estimate_messages[idx] = *incoming_flood; | 1162 | size_estimate_messages[idx] = *incoming_flood; |
1129 | size_estimate_messages[idx].hop_count = | 1163 | size_estimate_messages[idx].hop_count = |
1130 | htonl (ntohl (incoming_flood->hop_count) + 1); | 1164 | htonl (ntohl (incoming_flood->hop_count) + 1); |
@@ -1304,8 +1338,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
1304 | if (GNUNET_YES == check_proof_of_work (&my_public_key, my_proof)) | 1338 | if (GNUNET_YES == check_proof_of_work (&my_public_key, my_proof)) |
1305 | { | 1339 | { |
1306 | prev_time.abs_value = | 1340 | prev_time.abs_value = |
1307 | current_timestamp.abs_value - (estimate_index - | 1341 | current_timestamp.abs_value - gnunet_nse_interval.rel_value; |
1308 | 1) * gnunet_nse_interval.rel_value; | ||
1309 | setup_flood_message (estimate_index, prev_time); | 1342 | setup_flood_message (estimate_index, prev_time); |
1310 | estimate_count++; | 1343 | estimate_count++; |
1311 | } | 1344 | } |