aboutsummaryrefslogtreecommitdiff
path: root/src/setu/gnunet-service-setu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/setu/gnunet-service-setu.c')
-rw-r--r--src/setu/gnunet-service-setu.c62
1 files changed, 28 insertions, 34 deletions
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index b01b897d8..339d347f8 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -1119,15 +1119,16 @@ estimate_best_mode_of_operation (uint64_t avg_element_size,
1119 ibf_bucket_count = IBF_MIN_SIZE; 1119 ibf_bucket_count = IBF_MIN_SIZE;
1120 } 1120 }
1121 uint64_t ibf_message_count = ceil ( ((float) ibf_bucket_count) 1121 uint64_t ibf_message_count = ceil ( ((float) ibf_bucket_count)
1122 / MAX_BUCKETS_PER_MESSAGE); 1122 / ((float) MAX_BUCKETS_PER_MESSAGE));
1123 1123
1124 uint64_t estimated_counter_size = ceil ( 1124 uint64_t estimated_counter_size = ceil (
1125 MIN (2 * log2l ((float) local_set_size / ibf_bucket_count), log2l ( 1125 MIN (2 * log2l (((float) local_set_size)
1126 local_set_size))); 1126 / ((float) ibf_bucket_count)),
1127 log2l (local_set_size)));
1127 1128
1128 long double counter_bytes = (float) estimated_counter_size / 8; 1129 long double counter_bytes = (float) estimated_counter_size / 8;
1129 1130
1130 uint64_t ibf_bytes = ceil ((sizeof(struct IBFMessage) * ibf_message_count) 1131 uint64_t ibf_bytes = ceil ((sizeof (struct IBFMessage) * ibf_message_count)
1131 * 1.2 \ 1132 * 1.2 \
1132 + (ibf_bucket_count * sizeof(struct IBF_Key)) * 1.2 \ 1133 + (ibf_bucket_count * sizeof(struct IBF_Key)) * 1.2 \
1133 + (ibf_bucket_count * sizeof(struct IBF_KeyHash)) 1134 + (ibf_bucket_count * sizeof(struct IBF_KeyHash))
@@ -1135,18 +1136,18 @@ estimate_best_mode_of_operation (uint64_t avg_element_size,
1135 + (ibf_bucket_count * counter_bytes) * 1.2); 1136 + (ibf_bucket_count * counter_bytes) * 1.2);
1136 1137
1137 /* Estimate full byte count for differential sync */ 1138 /* Estimate full byte count for differential sync */
1138 uint64_t element_size = (avg_element_size + sizeof(struct 1139 uint64_t element_size = (avg_element_size
1139 GNUNET_SETU_ElementMessage)) \ 1140 + sizeof (struct GNUNET_SETU_ElementMessage)) \
1140 * estimated_total_diff; 1141 * estimated_total_diff;
1141 uint64_t done_size = sizeof_done_header; 1142 uint64_t done_size = sizeof_done_header;
1142 uint64_t inquery_size = (sizeof(struct IBF_Key) + sizeof(struct 1143 uint64_t inquery_size = (sizeof (struct IBF_Key)
1143 InquiryMessage)) 1144 + sizeof (struct InquiryMessage))
1144 * estimated_total_diff; 1145 * estimated_total_diff;
1145 uint64_t demand_size = 1146 uint64_t demand_size =
1146 (sizeof(struct GNUNET_HashCode) + sizeof(struct GNUNET_MessageHeader)) 1147 (sizeof(struct GNUNET_HashCode) + sizeof(struct GNUNET_MessageHeader))
1147 * estimated_total_diff; 1148 * estimated_total_diff;
1148 uint64_t offer_size = (sizeof(struct GNUNET_HashCode) + sizeof(struct 1149 uint64_t offer_size = (sizeof (struct GNUNET_HashCode)
1149 GNUNET_MessageHeader)) 1150 + sizeof (struct GNUNET_MessageHeader))
1150 * estimated_total_diff; 1151 * estimated_total_diff;
1151 1152
1152 uint64_t total_bytes_diff = (element_size + done_size + inquery_size 1153 uint64_t total_bytes_diff = (element_size + done_size + inquery_size
@@ -1183,12 +1184,13 @@ estimate_best_mode_of_operation (uint64_t avg_element_size,
1183 * @param allowed_phases 1184 * @param allowed_phases
1184 * @param size_phases 1185 * @param size_phases
1185 * @param op 1186 * @param op
1186 * @return GNUNET_YES if message permitted in phase and GNUNET_NO if not permitted in given 1187 * @return #GNUNET_YES if message permitted in phase and #GNUNET_NO if not permitted in given
1187 * phase 1188 * phase
1188 */ 1189 */
1189static int 1190static enum GNUNET_GenericReturnValue
1190check_valid_phase (const uint8_t allowed_phases[], size_t size_phases, struct 1191check_valid_phase (const uint8_t allowed_phases[],
1191 Operation *op) 1192 size_t size_phases,
1193 struct Operation *op)
1192{ 1194{
1193 /** 1195 /**
1194 * Iterate over allowed phases 1196 * Iterate over allowed phases
@@ -2146,11 +2148,15 @@ send_ibf (struct Operation *op,
2146 2148
2147 LOG (GNUNET_ERROR_TYPE_DEBUG, 2149 LOG (GNUNET_ERROR_TYPE_DEBUG,
2148 "sending ibf of size %u\n", 2150 "sending ibf of size %u\n",
2149 1 << ibf_size); 2151 (unsigned int) ibf_size);
2150 2152
2151 { 2153 {
2152 char name[64]; 2154 char name[64];
2153 GNUNET_snprintf (name, sizeof(name), "# sent IBF (order %u)", ibf_size); 2155
2156 GNUNET_snprintf (name,
2157 sizeof(name),
2158 "# sent IBF (order %u)",
2159 ibf_size);
2154 GNUNET_STATISTICS_update (_GSS_statistics, name, 1, GNUNET_NO); 2160 GNUNET_STATISTICS_update (_GSS_statistics, name, 1, GNUNET_NO);
2155 } 2161 }
2156 2162
@@ -4111,26 +4117,20 @@ handle_union_p2p_offer (void *cls,
4111 perf_store.demand.sent += 1; 4117 perf_store.demand.sent += 1;
4112 perf_store.demand.sent_var_bytes += sizeof(struct GNUNET_HashCode); 4118 perf_store.demand.sent_var_bytes += sizeof(struct GNUNET_HashCode);
4113#endif 4119#endif
4114 ev = GNUNET_MQ_msg_header_extra (demands,
4115 sizeof(struct GNUNET_HashCode),
4116 GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND);
4117 /* Save send demand message for message control */ 4120 /* Save send demand message for message control */
4118 if (GNUNET_YES != 4121 if (GNUNET_YES !=
4119 update_message_control_flow ( 4122 update_message_control_flow (
4120 op->message_control_flow, 4123 op->message_control_flow,
4121 MSG_CFS_SENT, 4124 MSG_CFS_SENT,
4122 hash, 4125 hash,
4123 DEMAND_MESSAGE) 4126 DEMAND_MESSAGE))
4124 )
4125 { 4127 {
4126 // GNUNET_free (ev);
4127 LOG (GNUNET_ERROR_TYPE_ERROR, 4128 LOG (GNUNET_ERROR_TYPE_ERROR,
4128 "Double demand message sent found!\n"); 4129 "Double demand message sent found!\n");
4129 GNUNET_break (0); 4130 GNUNET_break (0);
4130 fail_union_operation (op); 4131 fail_union_operation (op);
4131 return; 4132 return;
4132 } 4133 }
4133 ;
4134 4134
4135 /* Mark offer as received received */ 4135 /* Mark offer as received received */
4136 if (GNUNET_YES != 4136 if (GNUNET_YES !=
@@ -4138,37 +4138,31 @@ handle_union_p2p_offer (void *cls,
4138 op->message_control_flow, 4138 op->message_control_flow,
4139 MSG_CFS_RECEIVED, 4139 MSG_CFS_RECEIVED,
4140 hash, 4140 hash,
4141 OFFER_MESSAGE) 4141 OFFER_MESSAGE))
4142 )
4143 { 4142 {
4144 // GNUNET_free (ev);
4145 LOG (GNUNET_ERROR_TYPE_ERROR, 4143 LOG (GNUNET_ERROR_TYPE_ERROR,
4146 "Double offer message received found!\n"); 4144 "Double offer message received found!\n");
4147 GNUNET_break (0); 4145 GNUNET_break (0);
4148 fail_union_operation (op); 4146 fail_union_operation (op);
4149 return; 4147 return;
4150 } 4148 }
4151 ;
4152
4153 /* Mark element to be expected to received */ 4149 /* Mark element to be expected to received */
4154 if (GNUNET_YES != 4150 if (GNUNET_YES !=
4155 update_message_control_flow ( 4151 update_message_control_flow (
4156 op->message_control_flow, 4152 op->message_control_flow,
4157 MSG_CFS_EXPECTED, 4153 MSG_CFS_EXPECTED,
4158 hash, 4154 hash,
4159 ELEMENT_MESSAGE) 4155 ELEMENT_MESSAGE))
4160 )
4161 { 4156 {
4162 // GNUNET_free (ev);
4163 LOG (GNUNET_ERROR_TYPE_ERROR, 4157 LOG (GNUNET_ERROR_TYPE_ERROR,
4164 "Element already expected!\n"); 4158 "Element already expected!\n");
4165 GNUNET_break (0); 4159 GNUNET_break (0);
4166 fail_union_operation (op); 4160 fail_union_operation (op);
4167 return; 4161 return;
4168 } 4162 }
4169 ; 4163 ev = GNUNET_MQ_msg_header_extra (demands,
4170 4164 sizeof(struct GNUNET_HashCode),
4171 4165 GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND);
4172 GNUNET_memcpy (&demands[1], 4166 GNUNET_memcpy (&demands[1],
4173 hash, 4167 hash,
4174 sizeof(struct GNUNET_HashCode)); 4168 sizeof(struct GNUNET_HashCode));