network size estimation service More...
#include "platform.h"
#include <math.h>
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_statistics_service.h"
#include "gnunet_core_service.h"
#include "gnunet_nse_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. More... | |
#define | DEBUG_NSE GNUNET_NO |
Generate extensive debug-level log messages? More... | |
#define | HISTORY_SIZE 64 |
Over how many values do we calculate the weighted average? More... | |
#define | NSE_PRIORITY |
Message priority to use. More... | |
#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. More... | |
static void | handle_start (void *cls, const struct GNUNET_MessageHeader *message) |
Handler for START message from client, triggers an immediate current network estimate notification. More... | |
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? More... | |
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? More... | |
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. More... | |
static struct GNUNET_TIME_Relative | get_transmit_delay (int round_offset) |
Get the transmission delay that should be applied for a particular round. More... | |
static void | transmit_task_cb (void *cls) |
Task that triggers a NSE P2P transmission. More... | |
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. More... | |
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. More... | |
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. More... | |
static void | update_flood_message (void *cls) |
Update our flood message to be sent (and our timestamps). More... | |
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. More... | |
static void | write_proof (void) |
Write our current proof to disk. More... | |
static void | find_proof (void *cls) |
Find our proof of work. More... | |
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. More... | |
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. More... | |
static void | handle_p2p_estimate (void *cls, const struct GNUNET_NSE_FloodMessage *incoming_flood) |
Core handler for size estimate flooding messages. More... | |
static void * | handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq) |
Method called whenever a peer connects. More... | |
static void | handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls) |
Method called whenever a peer disconnects. More... | |
static void | shutdown_task (void *cls) |
Task run during shutdown. More... | |
static void | core_init (void *cls, const struct GNUNET_PeerIdentity *identity) |
Called on core init/fail. More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) |
Handle network size estimate clients. More... | |
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. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls) |
Callback called when a client disconnected from the service. More... | |
GNUNET_SERVICE_MAIN ("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. More... | |
Variables | |
static unsigned long long | nse_work_required |
Amount of work required (W-bit collisions) for NSE proofs, in collision-bits. More... | |
static struct GNUNET_TIME_Relative | gnunet_nse_interval |
Interval for sending network size estimation flood requests. More... | |
static struct GNUNET_TIME_Relative | proof_find_delay |
Interval between proof find runs. More... | |
static struct GNUNET_CRYPTO_PowSalt | salt = { "gnunet-nse-proof" } |
Salt for PoW calcualations. More... | |
static GNUNET_NETWORK_STRUCT_END const struct GNUNET_CONFIGURATION_Handle * | cfg |
Handle to our current configuration. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
Handle to the statistics service. More... | |
static struct GNUNET_CORE_Handle * | core_api |
Handle to the core service. More... | |
static struct GNUNET_CONTAINER_MultiPeerMap * | peers |
Map of all connected peers. More... | |
static double | current_size_estimate |
The current network size estimate. More... | |
static double | current_std_dev = NAN |
The standard deviation of the last HISTORY_SIZE network size estimates. More... | |
static uint32_t | hop_count_max |
Current hop counter estimate (estimate for network diameter). More... | |
static struct GNUNET_NSE_FloodMessage | next_message |
Message for the next round, if we got any. More... | |
static struct GNUNET_NSE_FloodMessage | size_estimate_messages [64] |
Array of recent size estimate messages. More... | |
static unsigned int | estimate_index |
Index of most recent estimate. More... | |
static unsigned int | estimate_count |
Number of valid entries in the history. More... | |
static struct GNUNET_SCHEDULER_Task * | flood_task |
Task scheduled to update our flood message for the next round. More... | |
static struct GNUNET_SCHEDULER_Task * | proof_task |
Task scheduled to compute our proof. More... | |
static struct GNUNET_NotificationContext * | nc |
Notification context, simplifies client broadcasts. More... | |
static struct GNUNET_TIME_Absolute | next_timestamp |
The next major time. More... | |
static struct GNUNET_TIME_Absolute | current_timestamp |
The current major time. More... | |
static struct GNUNET_CRYPTO_EddsaPrivateKey * | my_private_key |
The private key of this peer. More... | |
static struct GNUNET_PeerIdentity | my_identity |
The peer identity of this peer. More... | |
static uint64_t | my_proof |
Proof of work for this peer. More... | |
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 58 of file gnunet-service-nse.c.
#define DEBUG_NSE GNUNET_NO |
Generate extensive debug-level log messages?
Definition at line 63 of file gnunet-service-nse.c.
#define HISTORY_SIZE 64 |
Over how many values do we calculate the weighted average?
Definition at line 68 of file gnunet-service-nse.c.
#define NSE_PRIORITY |
Message priority to use.
No real rush, reliability not required. Corking OK.
Definition at line 74 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 327 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, consensus-simulation::sum, 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 428 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 453 of file gnunet-service-nse.c.
|
static |
What delay randomization should we apply for a given number of matching bits?
matching_bits | number of matching bits |
Definition at line 453 of file gnunet-service-nse.c.
References current_size_estimate, gnunet_nse_interval, matching_bits, and GNUNET_TIME_Relative::rel_value_us.
|
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 503 of file gnunet-service-nse.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_count_leading_zeros(), and GNUNET_CRYPTO_hash_xor().
Referenced by check_proof_of_work(), and setup_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 503 of file gnunet-service-nse.c.
Referenced by handle_core_connect(), schedule_current_round(), transmit_task_cb(), and update_flood_times().
|
static |
Task that triggers a NSE P2P transmission.
cls | the struct NSEPeerEntry * |
Definition at line 581 of file gnunet-service-nse.c.
References env, estimate_index, get_transmit_delay(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_NO, 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::mq, NSEPeerEntry::previous_round, proof_task, size_estimate_messages, stats, and NSEPeerEntry::transmit_task.
Referenced by handle_core_connect(), handle_p2p_estimate(), schedule_current_round(), 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 645 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().
|
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 662 of file gnunet-service-nse.c.
References get_matching_bits(), GNUNET_assert, GNUNET_CRYPTO_eddsa_sign_(), GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_NSE_SEND, GNUNET_TIME_absolute_hton(), GNUNET_NSE_FloodMessage::header, GNUNET_NSE_FloodMessage::hop_count, GNUNET_NSE_FloodMessage::matching_bits, matching_bits, my_identity, my_private_key, my_proof, nse_work_required, GNUNET_NSE_FloodMessage::origin, GNUNET_NSE_FloodMessage::proof_of_work, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_NSE_FloodMessage::purpose, GNUNET_NSE_FloodMessage::signature, GNUNET_MessageHeader::size, GNUNET_CRYPTO_EccSignaturePurpose::size, size_estimate_messages, GNUNET_NSE_FloodMessage::timestamp, and GNUNET_MessageHeader::type.
Referenced by check_proof_of_work(), core_init(), and find_proof().
|
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 701 of file gnunet-service-nse.c.
References delay, 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 check_proof_of_work().
|
static |
Update our flood message to be sent (and our timestamps).
cls | unused |
Definition at line 739 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), and core_init().
|
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 739 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_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, 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 core_init(), and verify_message_crypto().
|
static |
Write our current proof to disk.
Definition at line 817 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 847 of file gnunet-service-nse.c.
References buf, current_timestamp, estimate_index, GNUNET_ALIGN, GNUNET_CRYPTO_hash_count_leading_zeros(), GNUNET_CRYPTO_pow_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, my_identity, my_proof, nse_work_required, proof_find_delay, proof_task, result, ROUND_SIZE, salt, setup_flood_message(), and write_proof().
Referenced by run().
|
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 915 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 951 of file gnunet-service-nse.c.
References delay, 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 991 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_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_snprintf(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TESTBED_LOGGER_write(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_ntoh(), GNUNET_YES, HISTORY_SIZE, GNUNET_NSE_FloodMessage::hop_count, hop_count_max, NSEPeerEntry::id, GNUNET_NSE_FloodMessage::matching_bits, matching_bits, my_identity, next_message, next_timestamp, origin, GNUNET_NSE_FloodMessage::origin, os, peers, 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 |
Definition at line 1165 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, peer, 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 1205 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, peer, peers, stats, and NSEPeerEntry::transmit_task.
Referenced by run().
|
static |
Task run during shutdown.
cls | unused |
Definition at line 1254 of file gnunet-service-nse.c.
References core_api, flood_task, GNUNET_BIO_write_close(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CORE_disconnect(), GNUNET_free, GNUNET_NO, GNUNET_notification_context_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_TESTBED_LOGGER_flush(), my_private_key, nc, peers, proof_task, stats, and write_proof().
Referenced by run().
|
static |
Called on core init/fail.
cls | service closure |
identity | the public identity of this peer |
Definition at line 1319 of file gnunet-service-nse.c.
References GNUNET_TIME_Absolute::abs_value_us, check_proof_of_work(), current_timestamp, estimate_count, estimate_index, flood_task, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memcmp, gnunet_nse_interval, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_YES, HISTORY_SIZE, identity, my_identity, my_proof, next_timestamp, 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 1393 of file gnunet-service-nse.c.
References _, cfg, core_api, core_init(), find_proof(), GNUNET_asprintf(), GNUNET_assert, GNUNET_BIO_write_open_file(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_CORE_connect(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_CRYPTO_eddsa_key_get_public(), 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_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, handle_core_connect(), handle_core_disconnect(), my_identity, my_private_key, my_proof, nc, nse_work_required, peers, pk, proof, proof_find_delay, proof_task, GNUNET_PeerIdentity::public_key, 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 1526 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 1544 of file gnunet-service-nse.c.
References GNUNET_assert.
GNUNET_SERVICE_MAIN | ( | "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 85 of file gnunet-service-nse.c.
Referenced by find_proof(), run(), setup_flood_message(), and verify_message_crypto().
|
static |
Interval for sending network size estimation flood requests.
Definition at line 85 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), core_init(), get_delay_randomization(), handle_p2p_estimate(), and run().
|
static |
Interval between proof find runs.
Definition at line 85 of file gnunet-service-nse.c.
Referenced by find_proof(), and run().
|
static |
Salt for PoW calcualations.
Definition at line 85 of file gnunet-service-nse.c.
Referenced by checkvec(), compute_global_id(), derive_h(), find_proof(), GNUNET_CRYPTO_ecdsa_sign_derived(), GNUNET_CRYPTO_hmac_derive_key(), GNUNET_CRYPTO_hmac_derive_key_v(), GNUNET_CRYPTO_pow_hash(), GNUNET_CRYPTO_symmetric_derive_iv(), GNUNET_CRYPTO_symmetric_derive_iv_v(), output_vectors(), salt_key(), unsalt_key(), and update_ax_by_kx().
|
static |
Handle to our current configuration.
Definition at line 225 of file gnunet-service-nse.c.
Referenced by run(), and write_proof().
|
static |
Handle to the statistics service.
Definition at line 230 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 core service.
Definition at line 235 of file gnunet-service-nse.c.
Referenced by run(), and shutdown_task().
|
static |
Map of all connected peers.
Definition at line 240 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), handle_core_connect(), handle_core_disconnect(), handle_p2p_estimate(), run(), setup_estimate_message(), and shutdown_task().
|
static |
The current network size estimate.
Number of bits matching on average thus far.
Definition at line 246 of file gnunet-service-nse.c.
Referenced by get_delay_randomization(), and setup_estimate_message().
|
static |
The standard deviation of the last HISTORY_SIZE network size estimates.
Definition at line 252 of file gnunet-service-nse.c.
Referenced by setup_estimate_message().
|
static |
Current hop counter estimate (estimate for network diameter).
Definition at line 257 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), and handle_p2p_estimate().
|
static |
Message for the next round, if we got any.
Definition at line 257 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), and handle_p2p_estimate().
|
static |
Array of recent size estimate messages.
Definition at line 257 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), handle_p2p_estimate(), setup_estimate_message(), setup_flood_message(), and transmit_task_cb().
|
static |
Index of most recent estimate.
Definition at line 272 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), core_init(), find_proof(), handle_p2p_estimate(), setup_estimate_message(), and transmit_task_cb().
|
static |
Number of valid entries in the history.
Definition at line 277 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), core_init(), and setup_estimate_message().
|
static |
Task scheduled to update our flood message for the next round.
Definition at line 282 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), core_init(), and shutdown_task().
|
static |
Task scheduled to compute our proof.
Definition at line 287 of file gnunet-service-nse.c.
Referenced by find_proof(), run(), shutdown_task(), and transmit_task_cb().
|
static |
Notification context, simplifies client broadcasts.
Definition at line 292 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 292 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), core_init(), and handle_p2p_estimate().
|
static |
The current major time.
Definition at line 292 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), core_init(), find_proof(), and handle_p2p_estimate().
|
static |
The private key of this peer.
Definition at line 307 of file gnunet-service-nse.c.
Referenced by run(), setup_flood_message(), and shutdown_task().
|
static |
The peer identity of this peer.
Definition at line 307 of file gnunet-service-nse.c.
Referenced by check_proof_of_work(), core_init(), find_proof(), handle_p2p_estimate(), run(), and setup_flood_message().
|
static |
Proof of work for this peer.
Definition at line 317 of file gnunet-service-nse.c.
Referenced by core_init(), find_proof(), run(), setup_flood_message(), and write_proof().