diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-13 10:32:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-13 10:32:00 +0000 |
commit | 5e982700c48152c0a259d2d98a576b319fb68b8f (patch) | |
tree | d5c2adf1294012f943dfb90c5d436ac5b1f5c0b3 /src/dht/gnunet-service-dht.c | |
parent | d97e42d24a1e12455e5f9f25b7aeb521fd920502 (diff) | |
download | gnunet-5e982700c48152c0a259d2d98a576b319fb68b8f.tar.gz gnunet-5e982700c48152c0a259d2d98a576b319fb68b8f.zip |
NSE also replaces diameter
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 43 |
1 files changed, 10 insertions, 33 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 57ac618a0..ae6041452 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -26,7 +26,6 @@ | |||
26 | * | 26 | * |
27 | * TODO: | 27 | * TODO: |
28 | * - decide which 'benchmark'/test functions to keep | 28 | * - decide which 'benchmark'/test functions to keep |
29 | * - estiamte_diameter? | ||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #include "platform.h" | 31 | #include "platform.h" |
@@ -2996,25 +2995,6 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2996 | route_message (msg, msg_ctx); | 2995 | route_message (msg, msg_ctx); |
2997 | } | 2996 | } |
2998 | 2997 | ||
2999 | /** | ||
3000 | * Estimate the diameter of the network based | ||
3001 | * on how many buckets are currently in use. | ||
3002 | * Concept here is that the diameter of the network | ||
3003 | * is roughly the distance a message must travel in | ||
3004 | * order to reach its intended destination. Since | ||
3005 | * at each hop we expect to get one bit closer, and | ||
3006 | * we have one bit per bucket, the number of buckets | ||
3007 | * in use should be the largest number of hops for | ||
3008 | * a successful message. (of course, this assumes we | ||
3009 | * know all peers in the network!) | ||
3010 | * | ||
3011 | * @return ballpark diameter figure | ||
3012 | */ | ||
3013 | static unsigned int | ||
3014 | estimate_diameter () | ||
3015 | { | ||
3016 | return MAX_BUCKETS - lowest_bucket; | ||
3017 | } | ||
3018 | 2998 | ||
3019 | /** | 2999 | /** |
3020 | * To how many peers should we (on average) | 3000 | * To how many peers should we (on average) |
@@ -3035,9 +3015,6 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3035 | uint32_t random_value; | 3015 | uint32_t random_value; |
3036 | unsigned int forward_count; | 3016 | unsigned int forward_count; |
3037 | float target_value; | 3017 | float target_value; |
3038 | unsigned int diameter; | ||
3039 | |||
3040 | diameter = estimate_diameter (); | ||
3041 | 3018 | ||
3042 | /** | 3019 | /** |
3043 | * If we are behaving in strict kademlia mode, send multiple initial requests, | 3020 | * If we are behaving in strict kademlia mode, send multiple initial requests, |
@@ -3059,9 +3036,9 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3059 | if (hop_count > log_of_network_size_estimate * 2.0) | 3036 | if (hop_count > log_of_network_size_estimate * 2.0) |
3060 | { | 3037 | { |
3061 | #if DEBUG_DHT | 3038 | #if DEBUG_DHT |
3062 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3039 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3063 | "`%s:%s': Hop count too high (est %d, lowest %d), NOT Forwarding request\n", | 3040 | "Hop count too high (est %f, lowest %d), NOT Forwarding request\n", |
3064 | my_short_id, "DHT", estimate_diameter (), lowest_bucket); | 3041 | log_of_network_size_estimate * 2.0, lowest_bucket); |
3065 | #endif | 3042 | #endif |
3066 | /* FIXME: does this work as intended, isn't the decision to forward or not made based on closeness as well? */ | 3043 | /* FIXME: does this work as intended, isn't the decision to forward or not made based on closeness as well? */ |
3067 | if (GNUNET_YES == paper_forwarding) /* Once we have reached our ideal number of hops, don't stop forwarding! */ | 3044 | if (GNUNET_YES == paper_forwarding) /* Once we have reached our ideal number of hops, don't stop forwarding! */ |
@@ -3076,7 +3053,7 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3076 | { | 3053 | { |
3077 | /* FIXME: re-run replication trials with this formula */ | 3054 | /* FIXME: re-run replication trials with this formula */ |
3078 | target_value = | 3055 | target_value = |
3079 | 1 + (target_replication - 1.0) / (diameter + | 3056 | 1 + (target_replication - 1.0) / (log_of_network_size_estimate + |
3080 | ((float) (target_replication - 1.0) * | 3057 | ((float) (target_replication - 1.0) * |
3081 | hop_count)); | 3058 | hop_count)); |
3082 | /* Set forward count to floor of target_value */ | 3059 | /* Set forward count to floor of target_value */ |
@@ -3094,7 +3071,7 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3094 | random_value = 0; | 3071 | random_value = 0; |
3095 | forward_count = 1; | 3072 | forward_count = 1; |
3096 | target_value = | 3073 | target_value = |
3097 | target_replication / (diameter + | 3074 | target_replication / (log_of_network_size_estimate + |
3098 | ((float) target_replication * hop_count)); | 3075 | ((float) target_replication * hop_count)); |
3099 | if (target_value > 1) | 3076 | if (target_value > 1) |
3100 | { | 3077 | { |
@@ -3732,7 +3709,7 @@ republish_content_iterator (void *cls, struct GNUNET_TIME_Absolute exp, | |||
3732 | (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX)); | 3709 | (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX)); |
3733 | new_msg_ctx->replication = ntohl (DEFAULT_PUT_REPLICATION); | 3710 | new_msg_ctx->replication = ntohl (DEFAULT_PUT_REPLICATION); |
3734 | new_msg_ctx->msg_options = ntohl (0); | 3711 | new_msg_ctx->msg_options = ntohl (0); |
3735 | new_msg_ctx->network_size = estimate_diameter (); | 3712 | new_msg_ctx->network_size = log_of_network_size_estimate; |
3736 | new_msg_ctx->peer = &my_identity; | 3713 | new_msg_ctx->peer = &my_identity; |
3737 | new_msg_ctx->bloom = | 3714 | new_msg_ctx->bloom = |
3738 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 3715 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
@@ -3936,7 +3913,7 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3936 | (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX)); | 3913 | (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX)); |
3937 | msg_ctx.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION); | 3914 | msg_ctx.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION); |
3938 | msg_ctx.msg_options = ntohl (0); | 3915 | msg_ctx.msg_options = ntohl (0); |
3939 | msg_ctx.network_size = estimate_diameter (); | 3916 | msg_ctx.network_size = log_of_network_size_estimate; |
3940 | msg_ctx.peer = &my_identity; | 3917 | msg_ctx.peer = &my_identity; |
3941 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE; | 3918 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE; |
3942 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 3919 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |
@@ -3986,7 +3963,7 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3986 | (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX)); | 3963 | (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX)); |
3987 | msg_ctx.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION); | 3964 | msg_ctx.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION); |
3988 | msg_ctx.msg_options = ntohl (0); | 3965 | msg_ctx.msg_options = ntohl (0); |
3989 | msg_ctx.network_size = estimate_diameter (); | 3966 | msg_ctx.network_size = log_of_network_size_estimate; |
3990 | msg_ctx.peer = &my_identity; | 3967 | msg_ctx.peer = &my_identity; |
3991 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE; | 3968 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE; |
3992 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 3969 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |
@@ -4114,7 +4091,7 @@ send_find_peer_message (void *cls, | |||
4114 | (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX)); | 4091 | (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX)); |
4115 | msg_ctx.replication = DHT_DEFAULT_FIND_PEER_REPLICATION; | 4092 | msg_ctx.replication = DHT_DEFAULT_FIND_PEER_REPLICATION; |
4116 | msg_ctx.msg_options = DHT_DEFAULT_FIND_PEER_OPTIONS; | 4093 | msg_ctx.msg_options = DHT_DEFAULT_FIND_PEER_OPTIONS; |
4117 | msg_ctx.network_size = estimate_diameter (); | 4094 | msg_ctx.network_size = log_of_network_size_estimate; |
4118 | msg_ctx.peer = &my_identity; | 4095 | msg_ctx.peer = &my_identity; |
4119 | msg_ctx.importance = DHT_DEFAULT_FIND_PEER_IMPORTANCE; | 4096 | msg_ctx.importance = DHT_DEFAULT_FIND_PEER_IMPORTANCE; |
4120 | msg_ctx.timeout = DHT_DEFAULT_FIND_PEER_TIMEOUT; | 4097 | msg_ctx.timeout = DHT_DEFAULT_FIND_PEER_TIMEOUT; |
@@ -4195,7 +4172,7 @@ handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
4195 | sizeof (struct GNUNET_PeerIdentity)); | 4172 | sizeof (struct GNUNET_PeerIdentity)); |
4196 | msg_ctx.path_history_len = 1; | 4173 | msg_ctx.path_history_len = 1; |
4197 | } | 4174 | } |
4198 | msg_ctx.network_size = estimate_diameter (); | 4175 | msg_ctx.network_size = log_of_network_size_estimate; |
4199 | msg_ctx.peer = &my_identity; /* FIXME bart NULL? Fix doxygen? */ | 4176 | msg_ctx.peer = &my_identity; /* FIXME bart NULL? Fix doxygen? */ |
4200 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 4; /* Make local routing a higher priority */ | 4177 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 4; /* Make local routing a higher priority */ |
4201 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 4178 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |