network size estimation service More...
#include "gnunet_common.h"#include "platform.h"#include <math.h>#include "gnunet_util_lib.h"#include "gnunet_hello_uri_lib.h"#include "gnunet_protocols.h"#include "gnunet_signatures.h"#include "gnunet_statistics_service.h"#include "gnunet_core_service.h"#include "gnunet_pils_service.h"#include "nse.h"#include <gcrypt.h>Go to the source code of this file.
Data Structures | |
| struct | NSEPeerEntry |
| Per-peer information. More... | |
| struct | GNUNET_NSE_FloodMessage |
| Network size estimate reply; sent when "this" peer's timer has run out before receiving a valid reply from another peer. More... | |
Macros | |
| #define | USE_RANDOM_DELAYS GNUNET_YES |
| Should messages be delayed randomly? This option should be set to GNUNET_NO only for experiments, not in production. | |
| #define | DEBUG_NSE GNUNET_NO |
| Generate extensive debug-level log messages? | |
| #define | HISTORY_SIZE 64 |
| Over how many values do we calculate the weighted average? | |
| #define | NSE_PRIORITY |
| Message priority to use. | |
| #define | WEST 1 |
| #define | ROUND_SIZE 10 |
Functions | |
| static void | setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) |
| Initialize a message to clients with the current network size estimate. | |
| static void | handle_start (void *cls, const struct GNUNET_MessageHeader *message) |
| Handler for START message from client, triggers an immediate current network estimate notification. | |
| static double | get_matching_bits_delay (uint32_t matching_bits) |
| How long should we delay a message to go the given number of matching bits? | |
| static struct GNUNET_TIME_Relative | get_delay_randomization (uint32_t matching_bits) |
| What delay randomization should we apply for a given number of matching bits? | |
| static uint32_t | get_matching_bits (struct GNUNET_TIME_Absolute timestamp, const struct GNUNET_PeerIdentity *id) |
| Get the number of matching bits that the given timestamp has to the given peer ID. | |
| static struct GNUNET_TIME_Relative | get_transmit_delay (int round_offset) |
| Get the transmission delay that should be applied for a particular round. | |
| static void | sign_message_before_send_cb (void *cls, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig) |
| static void | transmit_task_cb (void *cls) |
| Task that triggers a NSE P2P transmission. | |
| static void | update_network_size_estimate () |
| We've sent on our flood message or one that we received which was validated and closer than ours. | |
| static void | setup_flood_message (unsigned int slot, struct GNUNET_TIME_Absolute ts) |
| Setup a flood message in our history array at the given slot offset for the given timestamp. | |
| static int | schedule_current_round (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
| Schedule transmission for the given peer for the current round based on what we know about the desired delay. | |
| static void | update_flood_message (void *cls) |
| Update our flood message to be sent (and our timestamps). | |
| static enum GNUNET_GenericReturnValue | check_proof_of_work (const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, uint64_t val) |
| Check whether the given public key and integer are a valid proof of work. | |
| static void | write_proof (void) |
| Write our current proof to disk. | |
| static void | find_proof (void *cls) |
| Find our proof of work. | |
| static int | verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood) |
| An incoming flood message has been received which claims to have more bits matching than any we know in this time period. | |
| static int | update_flood_times (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
| Update transmissions for the given peer for the current round based on updated proximity information. | |
| static void | handle_p2p_estimate (void *cls, const struct GNUNET_NSE_FloodMessage *incoming_flood) |
| Core handler for size estimate flooding messages. | |
| static void * | handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq, enum GNUNET_CORE_PeerClass class) |
| Method called whenever a peer connects. | |
| static void | handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls) |
| Method called whenever a peer disconnects. | |
| static void | shutdown_task (void *cls) |
| Task run during shutdown. | |
| static void | pils_id_change_cb (void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *addr_hash) |
| static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) |
| Handle network size estimate clients. | |
| static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq) |
| Callback called when a client connects to the service. | |
| static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls) |
| Callback called when a client disconnected from the service. | |
| GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "nse", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(start, GNUNET_MESSAGE_TYPE_NSE_START, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_handler_end()) | |
| Define "main" method using service macro. | |
Variables | |
| static unsigned long long | nse_work_required |
| Amount of work required (W-bit collisions) for NSE proofs, in collision-bits. | |
| static struct GNUNET_TIME_Relative | gnunet_nse_interval |
| Interval for sending network size estimation flood requests. | |
| static struct GNUNET_TIME_Relative | proof_find_delay |
| Interval between proof find runs. | |
| static struct GNUNET_CRYPTO_PowSalt | salt = { "gnunet-nse-proof" } |
| Salt for PoW calculations. | |
| static GNUNET_NETWORK_STRUCT_END const struct GNUNET_CONFIGURATION_Handle * | cfg |
| Handle to our current configuration. | |
| static struct GNUNET_STATISTICS_Handle * | stats |
| Handle to the statistics service. | |
| static struct GNUNET_PILS_Handle * | pils |
| Handle to the PILS service. | |
| static struct GNUNET_CORE_Handle * | core_api |
| Handle to the core service. | |
| static struct GNUNET_CONTAINER_MultiPeerMap * | peers |
| Map of all connected peers. | |
| static double | current_size_estimate |
| The current network size estimate. | |
| static double | current_std_dev = NAN |
| The standard deviation of the last HISTORY_SIZE network size estimates. | |
| static uint32_t | hop_count_max |
| Current hop counter estimate (estimate for network diameter). | |
| static struct GNUNET_NSE_FloodMessage | next_message |
| Message for the next round, if we got any. | |
| static struct GNUNET_NSE_FloodMessage | size_estimate_messages [64] |
| Array of recent size estimate messages. | |
| static unsigned int | estimate_index |
| Index of most recent estimate. | |
| static unsigned int | estimate_count |
| Number of valid entries in the history. | |
| static struct GNUNET_SCHEDULER_Task * | flood_task |
| Task scheduled to update our flood message for the next round. | |
| static struct GNUNET_SCHEDULER_Task * | proof_task |
| Task scheduled to compute our proof. | |
| static struct GNUNET_NotificationContext * | nc |
| Notification context, simplifies client broadcasts. | |
| static struct GNUNET_TIME_Absolute | next_timestamp |
| The next major time. | |
| static struct GNUNET_TIME_Absolute | current_timestamp |
| The current major time. | |
| static uint64_t | my_proof |
| Proof of work for this peer. | |
network size estimation service
The purpose of this service is to estimate the size of the network. Given a specified interval, each peer hashes the most recent timestamp which is evenly divisible by that interval. This hash is compared in distance to the peer identity to choose an offset. The closer the peer identity to the hashed timestamp, the earlier the peer sends out a "nearest peer" message. The closest peer's message should thus be received before any others, which stops those peer from sending their messages at a later duration. So every peer should receive the same nearest peer message, and from this can calculate the expected number of peers in the network.
Definition in file gnunet-service-nse.c.
| #define USE_RANDOM_DELAYS GNUNET_YES |
Should messages be delayed randomly? This option should be set to GNUNET_NO only for experiments, not in production.
Definition at line 59 of file gnunet-service-nse.c.
| #define DEBUG_NSE GNUNET_NO |
Generate extensive debug-level log messages?
Definition at line 64 of file gnunet-service-nse.c.
| #define HISTORY_SIZE 64 |
Over how many values do we calculate the weighted average?
Definition at line 69 of file gnunet-service-nse.c.
| #define NSE_PRIORITY |
Message priority to use.
No real rush, reliability not required. Corking OK.
Definition at line 75 of file gnunet-service-nse.c.
| #define WEST 1 |
| #define ROUND_SIZE 10 |
|
static |
Initialize a message to clients with the current network size estimate.
| em | message to fill in |
Definition at line 333 of file gnunet-service-nse.c.
References current_size_estimate, current_std_dev, estimate_count, estimate_index, GNUNET_CONTAINER_multipeermap_size(), GNUNET_hton_double(), GNUNET_MAX, GNUNET_MESSAGE_TYPE_NSE_ESTIMATE, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_NSE_ClientMessage::header, HISTORY_SIZE, matching_bits, peers, q, GNUNET_NSE_ClientMessage::reserved, GNUNET_MessageHeader::size, GNUNET_NSE_ClientMessage::size_estimate, size_estimate_messages, stats, GNUNET_NSE_ClientMessage::std_deviation, GNUNET_NSE_ClientMessage::timestamp, and GNUNET_MessageHeader::type.
Referenced by handle_start(), and update_network_size_estimate().
|
static |
Handler for START message from client, triggers an immediate current network estimate notification.
Also, we remember the client for updates upon future estimate measurements.
| cls | client who sent the message |
| message | the message received |
Definition at line 434 of file gnunet-service-nse.c.
References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_notification_context_add(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_NSE_ClientMessage::header, mq, nc, and setup_estimate_message().
|
static |
How long should we delay a message to go the given number of matching bits?
| matching_bits | number of matching bits to consider |
Definition at line 459 of file gnunet-service-nse.c.
References current_size_estimate, gnunet_nse_interval, matching_bits, and GNUNET_TIME_Relative::rel_value_us.
Referenced by get_delay_randomization(), and get_transmit_delay().
|
static |
What delay randomization should we apply for a given number of matching bits?
| matching_bits | number of matching bits |
Definition at line 479 of file gnunet-service-nse.c.
References d, get_matching_bits_delay(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, hop_count_max, matching_bits, and ret.
Referenced by get_transmit_delay().
|
static |
Get the number of matching bits that the given timestamp has to the given peer ID.
| timestamp | time to generate key |
| id | peer identity to compare with |
Definition at line 509 of file gnunet-service-nse.c.
References GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_count_leading_zeros(), GNUNET_CRYPTO_hash_xor(), and timestamp().
Referenced by setup_flood_message(), and update_flood_message().
|
static |
Get the transmission delay that should be applied for a particular round.
| round_offset | -1 for the previous round (random delay between 0 and 50ms) 0 for the current round (based on our proximity to time key) |
Definition at line 538 of file gnunet-service-nse.c.
References current_timestamp, estimate_index, get_delay_randomization(), get_matching_bits_delay(), GNUNET_break, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_YES, matching_bits, GNUNET_TIME_Relative::rel_value_us, ret, and size_estimate_messages.
Referenced by handle_core_connect(), schedule_current_round(), transmit_task_cb(), and update_flood_times().
|
static |
Definition at line 582 of file gnunet-service-nse.c.
References env, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_NSE_FloodMessage::header, NSEPeerEntry::mq, NSEPeerEntry::next_index_to_send, NSEPeerEntry::pils_op, GNUNET_NSE_FloodMessage::signature, and size_estimate_messages.
Referenced by transmit_task_cb().
|
static |
Task that triggers a NSE P2P transmission.
| cls | the struct NSEPeerEntry * |
Definition at line 604 of file gnunet-service-nse.c.
References estimate_index, get_transmit_delay(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_PILS_sign_by_peer_identity(), GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_ntoh(), GNUNET_YES, HISTORY_SIZE, NSEPeerEntry::id, matching_bits, NSEPeerEntry::next_index_to_send, pils, NSEPeerEntry::pils_op, NSEPeerEntry::previous_round, proof_task, sign_message_before_send_cb(), size_estimate_messages, stats, timestamp(), NSEPeerEntry::transmit_task, and transmit_task_cb().
Referenced by handle_core_connect(), handle_p2p_estimate(), schedule_current_round(), transmit_task_cb(), and update_flood_times().
|
static |
We've sent on our flood message or one that we received which was validated and closer than ours.
Update the global list of recent messages and the average. Also re-broadcast the message to any clients.
Definition at line 671 of file gnunet-service-nse.c.
References GNUNET_notification_context_broadcast(), GNUNET_YES, GNUNET_NSE_ClientMessage::header, nc, and setup_estimate_message().
Referenced by handle_p2p_estimate(), and load_underlay().
|
static |
Setup a flood message in our history array at the given slot offset for the given timestamp.
| slot | index to use |
| ts | timestamp to use |
Definition at line 688 of file gnunet-service-nse.c.
References get_matching_bits(), GNUNET_assert, GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD, GNUNET_PILS_get_identity(), GNUNET_SIGNATURE_PURPOSE_NSE_SEND, GNUNET_TIME_absolute_hton(), GNUNET_NSE_FloodMessage::header, GNUNET_NSE_FloodMessage::hop_count, matching_bits, GNUNET_NSE_FloodMessage::matching_bits, my_identity, my_proof, GNUNET_NSE_FloodMessage::origin, pils, GNUNET_NSE_FloodMessage::proof_of_work, GNUNET_CRYPTO_SignaturePurpose::purpose, GNUNET_NSE_FloodMessage::purpose, GNUNET_NSE_FloodMessage::signature, GNUNET_MessageHeader::size, GNUNET_CRYPTO_SignaturePurpose::size, size_estimate_messages, GNUNET_NSE_FloodMessage::timestamp, and GNUNET_MessageHeader::type.
Referenced by find_proof(), pils_id_change_cb(), and update_flood_message().
|
static |
Schedule transmission for the given peer for the current round based on what we know about the desired delay.
| cls | unused |
| key | hash of peer identity |
| value | the struct NSEPeerEntry |
Definition at line 725 of file gnunet-service-nse.c.
References get_transmit_delay(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), key, NSEPeerEntry::previous_round, stats, NSEPeerEntry::transmit_task, transmit_task_cb(), and value.
Referenced by update_flood_message().
|
static |
Update our flood message to be sent (and our timestamps).
| cls | unused |
Definition at line 763 of file gnunet-service-nse.c.
References GNUNET_TIME_Absolute::abs_value_us, current_timestamp, estimate_count, estimate_index, flood_task, get_matching_bits(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_MAX, gnunet_nse_interval, GNUNET_PILS_get_identity(), GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_ntoh(), HISTORY_SIZE, GNUNET_NSE_FloodMessage::hop_count, hop_count_max, GNUNET_NSE_FloodMessage::matching_bits, my_identity, next_message, next_timestamp, peers, pils, GNUNET_TIME_Relative::rel_value_us, schedule_current_round(), setup_flood_message(), size_estimate_messages, GNUNET_NSE_FloodMessage::timestamp, and update_flood_message().
Referenced by pils_id_change_cb(), and update_flood_message().
|
static |
Check whether the given public key and integer are a valid proof of work.
| pkey | the public key |
| val | the integer |
Definition at line 820 of file gnunet-service-nse.c.
References GNUNET_ALIGN, GNUNET_CRYPTO_hash_count_leading_zeros(), GNUNET_CRYPTO_pow_hash(), GNUNET_memcpy, GNUNET_NO, GNUNET_YES, nse_work_required, pkey, result, and salt.
Referenced by pils_id_change_cb(), and verify_message_crypto().
|
static |
Write our current proof to disk.
Definition at line 846 of file gnunet-service-nse.c.
References cfg, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_DISK_directory_remove(), GNUNET_DISK_fn_write(), GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, GNUNET_OK, my_proof, and proof.
Referenced by find_proof(), and shutdown_task().
|
static |
Find our proof of work.
| cls | closure (unused) |
Definition at line 876 of file gnunet-service-nse.c.
References current_timestamp, estimate_index, find_proof(), GNUNET_ALIGN, GNUNET_assert, GNUNET_CRYPTO_hash_count_leading_zeros(), GNUNET_CRYPTO_pow_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_ntohll(), GNUNET_PILS_get_identity(), GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, my_identity, my_proof, nse_work_required, pils, proof_find_delay, proof_task, result, ROUND_SIZE, salt, setup_flood_message(), and write_proof().
Referenced by find_proof(), and pils_id_change_cb().
|
static |
An incoming flood message has been received which claims to have more bits matching than any we know in this time period.
Verify the signature and/or proof of work.
| incoming_flood | the message to verify |
Definition at line 947 of file gnunet-service-nse.c.
References check_proof_of_work(), GNUNET_break_op, GNUNET_CRYPTO_eddsa_verify_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_NSE_SEND, GNUNET_YES, nse_work_required, GNUNET_NSE_FloodMessage::origin, GNUNET_NSE_FloodMessage::proof_of_work, GNUNET_PeerIdentity::public_key, GNUNET_NSE_FloodMessage::purpose, and GNUNET_NSE_FloodMessage::signature.
Referenced by handle_p2p_estimate().
|
static |
Update transmissions for the given peer for the current round based on updated proximity information.
| cls | peer entry to exclude from updates |
| key | hash of peer identity |
| value | the struct NSEPeerEntry * of a peer to transmit to |
Definition at line 983 of file gnunet-service-nse.c.
References get_transmit_delay(), GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), key, NSEPeerEntry::previous_round, NSEPeerEntry::transmit_task, transmit_task_cb(), and value.
Referenced by handle_p2p_estimate().
|
static |
Core handler for size estimate flooding messages.
| cls | peer this message is from |
| incoming_flood | received message |
Definition at line 1023 of file gnunet-service-nse.c.
References GNUNET_TIME_Absolute::abs_value_us, current_timestamp, estimate_index, GNUNET_assert, GNUNET_BIO_write_int64(), GNUNET_break_op, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_log, GNUNET_MAX, GNUNET_memcmp, GNUNET_NO, gnunet_nse_interval, GNUNET_PILS_get_identity(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_snprintf(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_ntoh(), GNUNET_YES, HISTORY_SIZE, GNUNET_NSE_FloodMessage::hop_count, hop_count_max, NSEPeerEntry::id, matching_bits, GNUNET_NSE_FloodMessage::matching_bits, my_identity, next_message, next_timestamp, origin, GNUNET_NSE_FloodMessage::origin, peers, pils, NSEPeerEntry::previous_round, GNUNET_TIME_Relative::rel_value_us, size_estimate_messages, stats, t, GNUNET_NSE_FloodMessage::timestamp, NSEPeerEntry::transmit_task, transmit_task_cb(), update_flood_times(), update_network_size_estimate(), and verify_message_crypto().
|
static |
Method called whenever a peer connects.
Sets up the PeerEntry and schedules the initial size info transmission to this peer.
| cls | closure |
| peer | peer identity this notification is about |
| class | class of the connecting peer |
Definition at line 1203 of file gnunet-service-nse.c.
References get_transmit_delay(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MQ_set_options(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), NSEPeerEntry::id, mq, NSEPeerEntry::mq, NSE_PRIORITY, peers, stats, NSEPeerEntry::transmit_task, and transmit_task_cb().
Referenced by run().
|
static |
Method called whenever a peer disconnects.
Deletes the PeerEntry and cancels any pending transmission requests to that peer.
| cls | closure |
| peer | peer identity this notification is about |
| internal_cls | the struct NSEPeerEntry for the peer |
Definition at line 1244 of file gnunet-service-nse.c.
References GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, peers, stats, and NSEPeerEntry::transmit_task.
Referenced by run().
|
static |
Task run during shutdown.
| cls | unused |
Definition at line 1293 of file gnunet-service-nse.c.
References core_api, flood_task, GNUNET_BIO_write_close(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CORE_disconnect(), GNUNET_NO, GNUNET_notification_context_destroy(), GNUNET_PILS_disconnect(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), nc, peers, pils, proof_task, stats, and write_proof().
|
static |
Definition at line 1352 of file gnunet-service-nse.c.
References GNUNET_TIME_Absolute::abs_value_us, check_proof_of_work(), current_timestamp, estimate_count, estimate_index, find_proof(), flood_task, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, gnunet_nse_interval, GNUNET_PILS_get_identity(), GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_YES, HISTORY_SIZE, my_identity, my_proof, next_timestamp, pils, proof_task, GNUNET_PeerIdentity::public_key, GNUNET_TIME_Relative::rel_value_us, setup_flood_message(), and update_flood_message().
Referenced by run().
|
static |
Handle network size estimate clients.
| cls | closure |
| c | configuration to use |
| service | the initialized service |
Definition at line 1442 of file gnunet-service-nse.c.
References _, cfg, core_api, GNUNET_asprintf(), GNUNET_assert, GNUNET_BIO_write_open_file(), GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_CORE_connect(), GNUNET_CORE_SERVICE_NSE, GNUNET_DISK_file_test(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_config_invalid(), GNUNET_log_config_missing(), GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_notification_context_create(), gnunet_nse_interval, GNUNET_OK, GNUNET_PILS_connect(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, handle_core_connect(), handle_core_disconnect(), my_proof, nc, nse_work_required, peers, pils, pils_id_change_cb(), proof, proof_find_delay, GNUNET_CORE_ServiceInfo::service, service, shutdown_task, and stats.
|
static |
Callback called when a client connects to the service.
| cls | closure for the service |
| c | the new client that connected to the service |
| mq | the message queue used to send messages to the client |
Definition at line 1578 of file gnunet-service-nse.c.
References mq.
|
static |
Callback called when a client disconnected from the service.
| cls | closure for the service |
| c | the client that disconnected |
| internal_cls | should be equal to c |
Definition at line 1596 of file gnunet-service-nse.c.
References GNUNET_assert.
| GNUNET_SERVICE_MAIN | ( | GNUNET_OS_project_data_gnunet() | , |
| "nse" | , | ||
| GNUNET_SERVICE_OPTION_NONE | , | ||
| & | run, | ||
| & | client_connect_cb, | ||
| & | client_disconnect_cb, | ||
| NULL | , | ||
| GNUNET_MQ_hd_fixed_size(start, GNUNET_MESSAGE_TYPE_NSE_START, struct GNUNET_MessageHeader, NULL) | , | ||
| GNUNET_MQ_handler_end() | |||
| ) |
Define "main" method using service macro.
|
static |
Amount of work required (W-bit collisions) for NSE proofs, in collision-bits.
Definition at line 86 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), find_proof(), run(), and verify_message_crypto().
|
static |
Interval for sending network size estimation flood requests.
Definition at line 91 of file gnunet-service-nse.c.
Referenced by get_matching_bits_delay(), handle_p2p_estimate(), pils_id_change_cb(), run(), and update_flood_message().
|
static |
Interval between proof find runs.
Definition at line 96 of file gnunet-service-nse.c.
Referenced by find_proof(), and run().
|
static |
Salt for PoW calculations.
Definition at line 120 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), and find_proof().
|
static |
Handle to our current configuration.
Definition at line 236 of file gnunet-service-nse.c.
Referenced by run(), and write_proof().
|
static |
Handle to the statistics service.
Definition at line 241 of file gnunet-service-nse.c.
Referenced by handle_core_connect(), handle_core_disconnect(), handle_p2p_estimate(), run(), schedule_current_round(), setup_estimate_message(), shutdown_task(), and transmit_task_cb().
|
static |
Handle to the PILS service.
Definition at line 246 of file gnunet-service-nse.c.
Referenced by find_proof(), handle_p2p_estimate(), pils_id_change_cb(), run(), setup_flood_message(), shutdown_task(), transmit_task_cb(), and update_flood_message().
|
static |
Handle to the core service.
Definition at line 251 of file gnunet-service-nse.c.
Referenced by run(), and shutdown_task().
|
static |
Map of all connected peers.
Definition at line 256 of file gnunet-service-nse.c.
Referenced by handle_core_connect(), handle_core_disconnect(), handle_p2p_estimate(), run(), setup_estimate_message(), shutdown_task(), and update_flood_message().
|
static |
The current network size estimate.
Number of bits matching on average thus far.
Definition at line 262 of file gnunet-service-nse.c.
Referenced by get_matching_bits_delay(), and setup_estimate_message().
|
static |
The standard deviation of the last HISTORY_SIZE network size estimates.
Definition at line 268 of file gnunet-service-nse.c.
Referenced by setup_estimate_message().
|
static |
Current hop counter estimate (estimate for network diameter).
Definition at line 273 of file gnunet-service-nse.c.
Referenced by get_delay_randomization(), handle_p2p_estimate(), and update_flood_message().
|
static |
Message for the next round, if we got any.
Definition at line 278 of file gnunet-service-nse.c.
Referenced by dequeue_message_from_room(), handle_p2p_estimate(), and update_flood_message().
|
static |
Array of recent size estimate messages.
Definition at line 283 of file gnunet-service-nse.c.
Referenced by get_transmit_delay(), handle_p2p_estimate(), setup_estimate_message(), setup_flood_message(), sign_message_before_send_cb(), transmit_task_cb(), and update_flood_message().
|
static |
Index of most recent estimate.
Definition at line 288 of file gnunet-service-nse.c.
Referenced by find_proof(), get_transmit_delay(), handle_p2p_estimate(), pils_id_change_cb(), setup_estimate_message(), transmit_task_cb(), and update_flood_message().
|
static |
Number of valid entries in the history.
Definition at line 293 of file gnunet-service-nse.c.
Referenced by pils_id_change_cb(), setup_estimate_message(), and update_flood_message().
|
static |
Task scheduled to update our flood message for the next round.
Definition at line 298 of file gnunet-service-nse.c.
Referenced by pils_id_change_cb(), shutdown_task(), and update_flood_message().
|
static |
Task scheduled to compute our proof.
Definition at line 303 of file gnunet-service-nse.c.
Referenced by find_proof(), pils_id_change_cb(), shutdown_task(), and transmit_task_cb().
|
static |
Notification context, simplifies client broadcasts.
Definition at line 308 of file gnunet-service-nse.c.
Referenced by handle_start(), run(), shutdown_task(), and update_network_size_estimate().
|
static |
The next major time.
Definition at line 313 of file gnunet-service-nse.c.
Referenced by handle_p2p_estimate(), pils_id_change_cb(), and update_flood_message().
|
static |
The current major time.
Definition at line 318 of file gnunet-service-nse.c.
Referenced by find_proof(), get_transmit_delay(), handle_p2p_estimate(), pils_id_change_cb(), and update_flood_message().
|
static |
Proof of work for this peer.
Definition at line 323 of file gnunet-service-nse.c.
Referenced by find_proof(), pils_id_change_cb(), run(), setup_flood_message(), and write_proof().