diff options
Diffstat (limited to 'src/transport/gnunet-service-tng.c')
-rw-r--r-- | src/transport/gnunet-service-tng.c | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 27b1a20c7..2784ca99e 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -33,6 +33,11 @@ | |||
33 | * => congestion control, flow control, etc [PERFORMANCE-BASICS] | 33 | * => congestion control, flow control, etc [PERFORMANCE-BASICS] |
34 | * | 34 | * |
35 | * Optimizations: | 35 | * Optimizations: |
36 | * - When forwarding DV learn messages, if a peer is reached that | ||
37 | * has a *bidirectional* link to the origin beyond 1st hop, | ||
38 | * do NOT forward it to peers _other_ than the origin, as | ||
39 | * there is clearly a better path directly from the origin to | ||
40 | * whatever else we could reach. | ||
36 | * - AcknowledgementUUIDPs are overkill with 256 bits (128 would do) | 41 | * - AcknowledgementUUIDPs are overkill with 256 bits (128 would do) |
37 | * => Need 128 bit hash map though! [BANDWIDTH, MEMORY] | 42 | * => Need 128 bit hash map though! [BANDWIDTH, MEMORY] |
38 | * - queue_send_msg and route_message both by API design have to make copies | 43 | * - queue_send_msg and route_message both by API design have to make copies |
@@ -6013,9 +6018,6 @@ activate_core_visible_dv_path (struct DistanceVectorHop *hop) | |||
6013 | } | 6018 | } |
6014 | 6019 | ||
6015 | 6020 | ||
6016 | // FIXME: add logging logic from here! | ||
6017 | |||
6018 | |||
6019 | /** | 6021 | /** |
6020 | * We have learned a @a path through the network to some other peer, add it to | 6022 | * We have learned a @a path through the network to some other peer, add it to |
6021 | * our DV data structure (returning #GNUNET_YES on success). | 6023 | * our DV data structure (returning #GNUNET_YES on success). |
@@ -6069,9 +6071,18 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path, | |||
6069 | for (unsigned int i = 2; i < path_len; i++) | 6071 | for (unsigned int i = 2; i < path_len; i++) |
6070 | if (NULL != lookup_neighbour (&path[i])) | 6072 | if (NULL != lookup_neighbour (&path[i])) |
6071 | { | 6073 | { |
6072 | /* Useless path, we have a direct connection to some hop | 6074 | /* Useless path: we have a direct connection to some hop |
6073 | in the middle of the path, so this one doesn't even | 6075 | in the middle of the path, so this one is not even |
6074 | seem terribly useful for redundancy */ | 6076 | terribly useful for redundancy */ |
6077 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
6078 | "Path of %u hops useless: directly link to hop %u (%s)\n", | ||
6079 | path_len, | ||
6080 | i, | ||
6081 | GNUNET_i2s (&path[i])); | ||
6082 | GNUNET_STATISTICS_update (GST_stats, | ||
6083 | "# Useless DV path ignored: hop is neighbour", | ||
6084 | 1, | ||
6085 | GNUNET_NO); | ||
6075 | return GNUNET_SYSERR; | 6086 | return GNUNET_SYSERR; |
6076 | } | 6087 | } |
6077 | dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, &path[path_len - 1]); | 6088 | dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, &path[path_len - 1]); |
@@ -6137,8 +6148,13 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path, | |||
6137 | { | 6148 | { |
6138 | /* Some peer send DV learn messages too often, we are learning | 6149 | /* Some peer send DV learn messages too often, we are learning |
6139 | the same path faster than it would be useful; do not forward! */ | 6150 | the same path faster than it would be useful; do not forward! */ |
6151 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
6152 | "Rediscovered path too quickly, not forwarding further\n"); | ||
6140 | return GNUNET_NO; | 6153 | return GNUNET_NO; |
6141 | } | 6154 | } |
6155 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
6156 | "Refreshed known path to %s, forwarding further\n", | ||
6157 | GNUNET_i2s (&dv->target)); | ||
6142 | return GNUNET_YES; | 6158 | return GNUNET_YES; |
6143 | } | 6159 | } |
6144 | } | 6160 | } |
@@ -6148,9 +6164,15 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path, | |||
6148 | if (shorter_distance >= MAX_DV_PATHS_TO_TARGET) | 6164 | if (shorter_distance >= MAX_DV_PATHS_TO_TARGET) |
6149 | { | 6165 | { |
6150 | /* We have a shorter path already! */ | 6166 | /* We have a shorter path already! */ |
6167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
6168 | "Have many shorter DV paths %s, not forwarding further\n", | ||
6169 | GNUNET_i2s (&dv->target)); | ||
6151 | return GNUNET_NO; | 6170 | return GNUNET_NO; |
6152 | } | 6171 | } |
6153 | /* create new DV path entry */ | 6172 | /* create new DV path entry */ |
6173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
6174 | "Discovered new DV path to %s\n", | ||
6175 | GNUNET_i2s (&dv->target)); | ||
6154 | hop = GNUNET_malloc (sizeof (struct DistanceVectorHop) + | 6176 | hop = GNUNET_malloc (sizeof (struct DistanceVectorHop) + |
6155 | sizeof (struct GNUNET_PeerIdentity) * (path_len - 2)); | 6177 | sizeof (struct GNUNET_PeerIdentity) * (path_len - 2)); |
6156 | hop->next_hop = next_hop; | 6178 | hop->next_hop = next_hop; |
@@ -6240,6 +6262,10 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop, | |||
6240 | struct GNUNET_TIME_Relative nnd; | 6262 | struct GNUNET_TIME_Relative nnd; |
6241 | 6263 | ||
6242 | /* compute message for forwarding */ | 6264 | /* compute message for forwarding */ |
6265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
6266 | "Forwarding DV learn message originating from %s to %s\n", | ||
6267 | GNUNET_i2s (&msg->initiator), | ||
6268 | GNUNET_i2s2 (next_hop)); | ||
6243 | GNUNET_assert (nhops < MAX_DV_HOPS_ALLOWED); | 6269 | GNUNET_assert (nhops < MAX_DV_HOPS_ALLOWED); |
6244 | fwd = GNUNET_malloc (sizeof (struct TransportDVLearnMessage) + | 6270 | fwd = GNUNET_malloc (sizeof (struct TransportDVLearnMessage) + |
6245 | (nhops + 1) * sizeof (struct DVPathEntryP)); | 6271 | (nhops + 1) * sizeof (struct DVPathEntryP)); |
@@ -6481,7 +6507,10 @@ calculate_fork_degree (unsigned int hops_taken, | |||
6481 | double left; | 6507 | double left; |
6482 | 6508 | ||
6483 | if (hops_taken >= 64) | 6509 | if (hops_taken >= 64) |
6510 | { | ||
6511 | GNUNET_break (0); | ||
6484 | return 0; /* precaution given bitshift below */ | 6512 | return 0; /* precaution given bitshift below */ |
6513 | } | ||
6485 | for (unsigned int i = 1; i < hops_taken; i++) | 6514 | for (unsigned int i = 1; i < hops_taken; i++) |
6486 | { | 6515 | { |
6487 | /* For each hop, subtract the expected number of targets | 6516 | /* For each hop, subtract the expected number of targets |
@@ -6496,6 +6525,12 @@ calculate_fork_degree (unsigned int hops_taken, | |||
6496 | if (UINT32_MAX * left > | 6525 | if (UINT32_MAX * left > |
6497 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)) | 6526 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)) |
6498 | rnd++; /* round up */ | 6527 | rnd++; /* round up */ |
6528 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
6529 | "Forwarding DV learn message of %u hops %u(/%u/%u) times\n", | ||
6530 | hops_taken, | ||
6531 | rnd, | ||
6532 | eligible_count, | ||
6533 | neighbour_count); | ||
6499 | return rnd; | 6534 | return rnd; |
6500 | } | 6535 | } |
6501 | 6536 | ||
@@ -6518,6 +6553,9 @@ neighbour_store_dvmono_cb (void *cls, int success) | |||
6518 | } | 6553 | } |
6519 | 6554 | ||
6520 | 6555 | ||
6556 | // FIXME: add logging logic from here! | ||
6557 | |||
6558 | |||
6521 | /** | 6559 | /** |
6522 | * Communicator gave us a DV learn message. Process the request. | 6560 | * Communicator gave us a DV learn message. Process the request. |
6523 | * | 6561 | * |