diff options
author | Julius Bünger <buenger@mytum.de> | 2015-06-20 13:48:15 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-06-20 13:48:15 +0000 |
commit | 870240d44941110248077d90eece173528c061cb (patch) | |
tree | 93a3e378d5789bea393e991dc5ed44472d95c25a /src | |
parent | b69026bf6eadb70ab0a88a4f092b3a37db23e4c4 (diff) | |
download | gnunet-870240d44941110248077d90eece173528c061cb.tar.gz gnunet-870240d44941110248077d90eece173528c061cb.zip |
-logging and comments
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index b4dc152cc..63c9dcffa 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -139,7 +139,7 @@ struct PeerOutstandingOp | |||
139 | struct PeerContext | 139 | struct PeerContext |
140 | { | 140 | { |
141 | /** | 141 | /** |
142 | * In own gossip/sampler list, in other's gossip/sampler list | 142 | * Flags indicating status of peer |
143 | */ | 143 | */ |
144 | uint32_t peer_flags; | 144 | uint32_t peer_flags; |
145 | 145 | ||
@@ -251,13 +251,13 @@ static unsigned int sampler_size_est_need; | |||
251 | 251 | ||
252 | 252 | ||
253 | /** | 253 | /** |
254 | * Percentage of total peer number in the gossip list | 254 | * Percentage of total peer number in the view |
255 | * to send random PUSHes to | 255 | * to send random PUSHes to |
256 | */ | 256 | */ |
257 | static float alpha; | 257 | static float alpha; |
258 | 258 | ||
259 | /** | 259 | /** |
260 | * Percentage of total peer number in the gossip list | 260 | * Percentage of total peer number in the view |
261 | * to send random PULLs to | 261 | * to send random PULLs to |
262 | */ | 262 | */ |
263 | static float beta; | 263 | static float beta; |
@@ -611,7 +611,7 @@ get_rand_peer_ignore_list (const struct GNUNET_PeerIdentity *peer_list, | |||
611 | 611 | ||
612 | /**; | 612 | /**; |
613 | * Choose the r_index of the peer we want to return | 613 | * Choose the r_index of the peer we want to return |
614 | * at random from the interval of the gossip list | 614 | * at random from the interval of the view |
615 | */ | 615 | */ |
616 | r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, | 616 | r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, |
617 | tmp_size); | 617 | tmp_size); |
@@ -631,7 +631,7 @@ get_rand_peer_ignore_list (const struct GNUNET_PeerIdentity *peer_list, | |||
631 | 631 | ||
632 | /**; | 632 | /**; |
633 | * Choose the r_index of the peer we want to return | 633 | * Choose the r_index of the peer we want to return |
634 | * at random from the interval of the gossip list | 634 | * at random from the interval of the view |
635 | */ | 635 | */ |
636 | r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, | 636 | r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, |
637 | tmp_size); | 637 | tmp_size); |
@@ -677,7 +677,7 @@ get_peer_ctx (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, | |||
677 | 677 | ||
678 | 678 | ||
679 | /** | 679 | /** |
680 | * Put random peer from sampler into the gossip list as history update. | 680 | * Put random peer from sampler into the view as history update. |
681 | */ | 681 | */ |
682 | void | 682 | void |
683 | hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers) | 683 | hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers) |
@@ -1248,7 +1248,7 @@ new_peer_id (const struct GNUNET_PeerIdentity *peer_id) | |||
1248 | /** | 1248 | /** |
1249 | * Function called by NSE. | 1249 | * Function called by NSE. |
1250 | * | 1250 | * |
1251 | * Updates sizes of sampler list and gossip list and adapt those lists | 1251 | * Updates sizes of sampler list and view and adapt those lists |
1252 | * accordingly. | 1252 | * accordingly. |
1253 | */ | 1253 | */ |
1254 | void | 1254 | void |
@@ -1563,7 +1563,7 @@ generate_view_array (unsigned int view_size) | |||
1563 | /** | 1563 | /** |
1564 | * Handle PULL REQUEST request message from another peer. | 1564 | * Handle PULL REQUEST request message from another peer. |
1565 | * | 1565 | * |
1566 | * Reply with the gossip list of PeerIDs. | 1566 | * Reply with the view of PeerIDs. |
1567 | * | 1567 | * |
1568 | * @param cls Closure | 1568 | * @param cls Closure |
1569 | * @param channel The channel the PUSH was received over | 1569 | * @param channel The channel the PUSH was received over |
@@ -1584,6 +1584,8 @@ handle_peer_pull_request (void *cls, | |||
1584 | GNUNET_CADET_OPTION_PEER); | 1584 | GNUNET_CADET_OPTION_PEER); |
1585 | // FIXME wait for cadet to change this function | 1585 | // FIXME wait for cadet to change this function |
1586 | 1586 | ||
1587 | LOG (GNUNET_ERROR_TYPE_DEBUG, "PULL REQUEST received (%s)\n", GNUNET_i2s (peer)); | ||
1588 | |||
1587 | #ifdef ENABLE_MALICIOUS | 1589 | #ifdef ENABLE_MALICIOUS |
1588 | if (1 == mal_type | 1590 | if (1 == mal_type |
1589 | || 3 == mal_type) | 1591 | || 3 == mal_type) |
@@ -1665,8 +1667,12 @@ handle_peer_pull_reply (void *cls, | |||
1665 | // FIXME wait for cadet to change this function | 1667 | // FIXME wait for cadet to change this function |
1666 | sender_ctx = get_peer_ctx (peer_map, sender); | 1668 | sender_ctx = get_peer_ctx (peer_map, sender); |
1667 | 1669 | ||
1670 | LOG (GNUNET_ERROR_TYPE_DEBUG, "PULL REPLY received (%s)\n", GNUNET_i2s (sender)); | ||
1671 | |||
1668 | if (GNUNET_YES != get_peer_flag (sender_ctx, PULL_REPLY_PENDING)) | 1672 | if (GNUNET_YES != get_peer_flag (sender_ctx, PULL_REPLY_PENDING)) |
1669 | { | 1673 | { |
1674 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
1675 | "Received a pull reply from a peer we didn't request one from!\n"); | ||
1670 | GNUNET_break_op (0); | 1676 | GNUNET_break_op (0); |
1671 | return GNUNET_OK; | 1677 | return GNUNET_OK; |
1672 | } | 1678 | } |
@@ -1682,7 +1688,8 @@ handle_peer_pull_reply (void *cls, | |||
1682 | peers = (struct GNUNET_PeerIdentity *) &msg[1]; | 1688 | peers = (struct GNUNET_PeerIdentity *) &msg[1]; |
1683 | 1689 | ||
1684 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1690 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1685 | "PULL REPLY received, got following peers:\n"); | 1691 | "PULL REPLY received, got following %u peers:\n", |
1692 | ntohl (in_msg->num_peers)); | ||
1686 | 1693 | ||
1687 | for (i = 0 ; i < ntohl (in_msg->num_peers) ; i++) | 1694 | for (i = 0 ; i < ntohl (in_msg->num_peers) ; i++) |
1688 | { | 1695 | { |
@@ -1805,7 +1812,7 @@ send_pull_request (struct GNUNET_PeerIdentity *peer_id) | |||
1805 | set_peer_flag (peer_ctx, PULL_REPLY_PENDING); | 1812 | set_peer_flag (peer_ctx, PULL_REPLY_PENDING); |
1806 | 1813 | ||
1807 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1814 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1808 | "Sending PULL request to peer %s of gossiped list.\n", | 1815 | "Sending PULL request to peer %s of view.\n", |
1809 | GNUNET_i2s (peer_id)); | 1816 | GNUNET_i2s (peer_id)); |
1810 | 1817 | ||
1811 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); | 1818 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); |
@@ -1826,7 +1833,7 @@ send_push (struct GNUNET_PeerIdentity *peer_id) | |||
1826 | struct GNUNET_MQ_Handle *mq; | 1833 | struct GNUNET_MQ_Handle *mq; |
1827 | 1834 | ||
1828 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1835 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1829 | "Sending PUSH to peer %s of gossiped list.\n", | 1836 | "Sending PUSH to peer %s of view.\n", |
1830 | GNUNET_i2s (peer_id)); | 1837 | GNUNET_i2s (peer_id)); |
1831 | 1838 | ||
1832 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); | 1839 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); |
@@ -2088,7 +2095,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2088 | struct GNUNET_PeerIdentity peer; | 2095 | struct GNUNET_PeerIdentity peer; |
2089 | 2096 | ||
2090 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2097 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2091 | "Printing gossip list:\n"); | 2098 | "Printing view:\n"); |
2092 | to_file (file_name_view_log, | 2099 | to_file (file_name_view_log, |
2093 | "___ new round ___"); | 2100 | "___ new round ___"); |
2094 | view_size = GNUNET_CONTAINER_multipeermap_size (view); | 2101 | view_size = GNUNET_CONTAINER_multipeermap_size (view); |
@@ -2109,8 +2116,6 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2109 | permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, | 2116 | permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, |
2110 | (unsigned int) view_size); | 2117 | (unsigned int) view_size); |
2111 | 2118 | ||
2112 | /* generate view_array */ | ||
2113 | |||
2114 | /* Send PUSHes */ | 2119 | /* Send PUSHes */ |
2115 | a_peers = ceil (alpha * view_size); | 2120 | a_peers = ceil (alpha * view_size); |
2116 | 2121 | ||
@@ -2154,7 +2159,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2154 | 0 < push_list_size && | 2159 | 0 < push_list_size && |
2155 | 0 < pull_list_size) | 2160 | 0 < pull_list_size) |
2156 | { | 2161 | { |
2157 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Update of the gossip list.\n"); | 2162 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Update of the view.\n"); |
2158 | 2163 | ||
2159 | uint32_t first_border; | 2164 | uint32_t first_border; |
2160 | uint32_t second_border; | 2165 | uint32_t second_border; |
@@ -2172,9 +2177,9 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2172 | /* Seems like recreating is the easiest way of emptying the peermap */ | 2177 | /* Seems like recreating is the easiest way of emptying the peermap */ |
2173 | GNUNET_CONTAINER_multipeermap_destroy (view); | 2178 | GNUNET_CONTAINER_multipeermap_destroy (view); |
2174 | view = GNUNET_CONTAINER_multipeermap_create (view_size, GNUNET_NO); | 2179 | view = GNUNET_CONTAINER_multipeermap_create (view_size, GNUNET_NO); |
2180 | to_file (file_name_view_log, | ||
2181 | "--- emptied ---"); | ||
2175 | 2182 | ||
2176 | /* first_border = ceil (alpha * sampler_size_est_need); | ||
2177 | second_border = first_border + ceil (beta * sampler_size_est_need); */ | ||
2178 | first_border = GNUNET_MIN (ceil (alpha * sampler_size_est_need), | 2183 | first_border = GNUNET_MIN (ceil (alpha * sampler_size_est_need), |
2179 | push_list_size); | 2184 | push_list_size); |
2180 | second_border = first_border + | 2185 | second_border = first_border + |
@@ -2185,9 +2190,6 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2185 | 2190 | ||
2186 | GNUNET_array_grow (view_array, view_size, second_border); | 2191 | GNUNET_array_grow (view_array, view_size, second_border); |
2187 | 2192 | ||
2188 | to_file (file_name_view_log, | ||
2189 | "--- emptied ---"); | ||
2190 | |||
2191 | /* Update view with peers received through PUSHes */ | 2193 | /* Update view with peers received through PUSHes */ |
2192 | permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, | 2194 | permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, |
2193 | pull_list_size); | 2195 | pull_list_size); |
@@ -2198,7 +2200,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2198 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 2200 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
2199 | 2201 | ||
2200 | to_file (file_name_view_log, | 2202 | to_file (file_name_view_log, |
2201 | "+%s't(push list)", | 2203 | "+%s\t(push list)", |
2202 | GNUNET_i2s_full (&view_array[i])); | 2204 | GNUNET_i2s_full (&view_array[i])); |
2203 | // TODO change the peer_flags accordingly | 2205 | // TODO change the peer_flags accordingly |
2204 | } | 2206 | } |
@@ -2237,9 +2239,9 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2237 | for (i = 0; i < peers_to_clean_size; i++) | 2239 | for (i = 0; i < peers_to_clean_size; i++) |
2238 | { | 2240 | { |
2239 | peer_clean (&peers_to_clean[i]); | 2241 | peer_clean (&peers_to_clean[i]); |
2240 | /* to_file (file_name_view_log, | 2242 | to_file (file_name_view_log, |
2241 | "-%s", | 2243 | "-%s", |
2242 | GNUNET_i2s_full (&peers_to_clean[i])); */ | 2244 | GNUNET_i2s_full (&peers_to_clean[i])); |
2243 | } | 2245 | } |
2244 | 2246 | ||
2245 | GNUNET_free (peers_to_clean); | 2247 | GNUNET_free (peers_to_clean); |
@@ -2247,7 +2249,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2247 | } | 2249 | } |
2248 | else | 2250 | else |
2249 | { | 2251 | { |
2250 | LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the gossip list.\n"); | 2252 | LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the view.\n"); |
2251 | } | 2253 | } |
2252 | // TODO independent of that also get some peers from CADET_get_peers()? | 2254 | // TODO independent of that also get some peers from CADET_get_peers()? |
2253 | 2255 | ||
@@ -2724,7 +2726,7 @@ run (void *cls, | |||
2724 | return; | 2726 | return; |
2725 | } | 2727 | } |
2726 | 2728 | ||
2727 | /* Get initial size of sampler/gossip list from the configuration */ | 2729 | /* Get initial size of sampler/view from the configuration */ |
2728 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "RPS", | 2730 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "RPS", |
2729 | "INITSIZE", | 2731 | "INITSIZE", |
2730 | (long long unsigned int *) &sampler_size_est_need)) | 2732 | (long long unsigned int *) &sampler_size_est_need)) |