[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 122/164: Improved code and commtents
From: |
gnunet |
Subject: |
[gnunet] 122/164: Improved code and commtents |
Date: |
Fri, 30 Jul 2021 15:33:08 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 0a0b803b2cf857d0e6f16cea11983d59c4d83c05
Author: Elias Summermatter <elias.summermatter@seccom.ch>
AuthorDate: Sun May 30 14:01:40 2021 +0200
Improved code and commtents
---
src/setu/gnunet-service-setu.c | 451 +++++++++++++++---------
src/setu/gnunet-service-setu_strata_estimator.c | 1 +
src/setu/gnunet-service-setu_strata_estimator.h | 1 +
src/setu/ibf.c | 1 +
src/setu/ibf.h | 1 +
src/setu/perf_setu_api.c | 1 +
src/setu/setu_api.c | 1 +
7 files changed, 287 insertions(+), 170 deletions(-)
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index 534585588..8921f6ce4 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -22,6 +22,7 @@
* @brief set union operation
* @author Florian Dold
* @author Christian Grothoff
+ * @author Elias Summermatter
*/
#include "platform.h"
#include "gnunet_util_lib.h"
@@ -50,10 +51,6 @@
*/
#define SE_STRATA_COUNT 32
-/**
- * Size of the IBFs in the strata estimator.
- */
-#define SE_IBF_SIZE 79
/**
* Primes for all 4 different strata estimators 61,67,71,73,79,83,89,97 348
@@ -77,12 +74,6 @@
*/
#define MAX_IBF_SIZE 1048576
-/**
- * Number of buckets used in the ibf per estimated
- * difference.
- */
-#define IBF_ALPHA 4
-
/**
* Calculate min of two given Values
*/
@@ -93,7 +84,7 @@
/**
* Minimal size of an ibf
*/
-#define IBF_MIN_SIZE 36
+#define IBF_MIN_SIZE 37
/**
* AVG RTT for differential sync when k=2 and Factor = 2
@@ -113,6 +104,12 @@
#define PROBABILITY_FOR_NEW_ROUND 0.15
+/**
+ * Measure the performance in a csv
+ */
+
+#define MEASURE_PERFORMANCE 1
+
/**
* Current phase we are in for a union operation.
@@ -181,11 +178,25 @@ enum UnionOperationPhase
PHASE_FULL_RECEIVING
};
+/**
+ * Different modes of operations
+ */
enum MODE_OF_OPERATION
{
+ /**
+ * Mode just synchronizes the difference between sets
+ */
DIFFERENTIAL_SYNC,
+
+ /**
+ * Mode send full set sending local set first
+ */
FULL_SYNC_LOCAL_SENDING_FIRST,
+
+ /**
+ * Mode request full set from remote peer
+ */
FULL_SYNC_REMOTE_SENDING_FIRST
};
@@ -763,32 +774,33 @@ static const struct GNUNET_CONFIGURATION_Handle *setu_cfg;
/**
- * Added Roundtripscounter
+ * Stores the performance data for induvidual message
*/
-
-
-struct perf_num_send_resived_msg {
+#if MEASURE_PERFORMANCE
+struct perf_num_send_received_msg {
int sent;
int sent_var_bytes;
int received;
int received_var_bytes;
};
-
-struct perf_rtt_struct
+/**
+ * Main struct to messure perfomance (data/rtts)
+ */
+struct per_store_struct
{
- struct perf_num_send_resived_msg operation_request;
- struct perf_num_send_resived_msg se;
- struct perf_num_send_resived_msg request_full;
- struct perf_num_send_resived_msg element_full;
- struct perf_num_send_resived_msg full_done;
- struct perf_num_send_resived_msg ibf;
- struct perf_num_send_resived_msg inquery;
- struct perf_num_send_resived_msg element;
- struct perf_num_send_resived_msg demand;
- struct perf_num_send_resived_msg offer;
- struct perf_num_send_resived_msg done;
- struct perf_num_send_resived_msg over;
+ struct perf_num_send_received_msg operation_request;
+ struct perf_num_send_received_msg se;
+ struct perf_num_send_received_msg request_full;
+ struct perf_num_send_received_msg element_full;
+ struct perf_num_send_received_msg full_done;
+ struct perf_num_send_received_msg ibf;
+ struct perf_num_send_received_msg inquery;
+ struct perf_num_send_received_msg element;
+ struct perf_num_send_received_msg demand;
+ struct perf_num_send_received_msg offer;
+ struct perf_num_send_received_msg done;
+ struct perf_num_send_received_msg over;
int se_diff;
int se_diff_remote;
int se_diff_local;
@@ -796,8 +808,12 @@ struct perf_rtt_struct
uint8_t mode_of_operation;
};
-struct perf_rtt_struct perf_rtt;
+struct per_store_struct perf_store;
+#endif
+/**
+ * Different states to control the messages flow in differential mode
+ */
enum MESSAGE_CONTROL_FLOW_STATE
{
@@ -807,6 +823,10 @@ enum MESSAGE_CONTROL_FLOW_STATE
MESSAGE_RECEIVED,
};
+/**
+ * Message types to track in message control flow
+ */
+
enum MESSAGE_TYPE
{
OFFER_MESSAGE,
@@ -814,6 +834,10 @@ enum MESSAGE_TYPE
ELEMENT_MESSAGE,
};
+/**
+ * Struct to tracked messages in message controll flow
+ */
+
struct message_control_flow_element
{
enum MESSAGE_CONTROL_FLOW_STATE offer;
@@ -822,7 +846,11 @@ struct message_control_flow_element
};
-
+#if MEASURE_PERFORMANCE
+/**
+ * Loads different configuration to do perform perfomance tests
+ * @param op
+ */
static void
load_config(struct Operation * op) {
@@ -850,18 +878,24 @@ load_config(struct Operation * op) {
op->active_passive_switches = 0;
}
-
-
+/**
+ * Function to calculate total bytes used for performance messurement
+ * @param size
+ * @param perf_num_send_received_msg
+ * @return bytes used
+ */
static int
-sum_sent_received_bytes(int size, struct perf_num_send_resived_msg
perf_rtt_struct) {
- return (size * perf_rtt_struct.sent) +
- (size * perf_rtt_struct.received) +
- perf_rtt_struct.sent_var_bytes +
- perf_rtt_struct.received_var_bytes;
+sum_sent_received_bytes(int size, struct perf_num_send_received_msg
perf_num_send_received_msg) {
+ return (size * perf_num_send_received_msg.sent) +
+ (size * perf_num_send_received_msg.received) +
+ perf_num_send_received_msg.sent_var_bytes +
+ perf_num_send_received_msg.received_var_bytes;
}
-
-static float
-calculate_perf_rtt() {
+/**
+ * Function that calculates the perfmance values and writes them down
+ */
+static void
+calculate_perf_store() {
/**
* Calculate RTT of init phase normally always 1
@@ -872,21 +906,21 @@ calculate_perf_rtt() {
/**
* Calculate RGNUNET_SETU_AcceptMessageRT of Fullsync normally 1 or 1.5
depending
*/
- if (( perf_rtt.element_full.received != 0 ) ||
- ( perf_rtt.element_full.sent != 0)
+ if (( perf_store.element_full.received != 0 ) ||
+ ( perf_store.element_full.sent != 0)
) rtt += 1;
- if (( perf_rtt.request_full.received != 0 ) ||
- ( perf_rtt.request_full.sent != 0)
+ if (( perf_store.request_full.received != 0 ) ||
+ ( perf_store.request_full.sent != 0)
) rtt += 0.5;
/**
* In case of a differential sync 3 rtt's are needed.
* for every active/passive switch additional 3.5 rtt's are used
*/
- if (( perf_rtt.element.received != 0 ) ||
- ( perf_rtt.element.sent != 0)) {
- int iterations = perf_rtt.active_passive_switches;
+ if (( perf_store.element.received != 0 ) ||
+ ( perf_store.element.sent != 0)) {
+ int iterations = perf_store.active_passive_switches;
if(iterations > 0)
rtt += iterations * 0.5;
@@ -897,21 +931,20 @@ calculate_perf_rtt() {
/**
* Calculate data sended size
*/
- bytes_transmitted += sum_sent_received_bytes(4, perf_rtt.request_full);
-
- bytes_transmitted += sum_sent_received_bytes(sizeof(struct
GNUNET_SETU_ElementMessage), perf_rtt.element_full);
- bytes_transmitted += sum_sent_received_bytes(sizeof(struct
GNUNET_SETU_ElementMessage), perf_rtt.element);
- // bytes_transmitted +=
sum_sent_received_bytes(sizeof(GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST),
perf_rtt.operation_request);
- // bytes_transmitted +=
sum_sent_received_bytes(sizeof(GNUNET_MESSAGE_TYPE_SETU_P2P_SE), perf_rtt.se);
- bytes_transmitted += sum_sent_received_bytes(4, perf_rtt.full_done);
- bytes_transmitted += sum_sent_received_bytes(sizeof(struct IBFMessage),
perf_rtt.ibf);
- bytes_transmitted += sum_sent_received_bytes(sizeof(struct
InquiryMessage), perf_rtt.inquery);
- bytes_transmitted += sum_sent_received_bytes(sizeof(struct
GNUNET_MessageHeader), perf_rtt.demand);
- bytes_transmitted += sum_sent_received_bytes(sizeof(struct
GNUNET_MessageHeader), perf_rtt.offer);
- bytes_transmitted += sum_sent_received_bytes(4, perf_rtt.done);
+ bytes_transmitted += sum_sent_received_bytes(4, perf_store.request_full);
+
+ bytes_transmitted += sum_sent_received_bytes(sizeof(struct
GNUNET_SETU_ElementMessage), perf_store.element_full);
+ bytes_transmitted += sum_sent_received_bytes(sizeof(struct
GNUNET_SETU_ElementMessage), perf_store.element);
+ // bytes_transmitted +=
sum_sent_received_bytes(sizeof(GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST),
perf_store.operation_request);
+ // bytes_transmitted +=
sum_sent_received_bytes(sizeof(GNUNET_MESSAGE_TYPE_SETU_P2P_SE), perf_store.se);
+ bytes_transmitted += sum_sent_received_bytes(4, perf_store.full_done);
+ bytes_transmitted += sum_sent_received_bytes(sizeof(struct IBFMessage),
perf_store.ibf);
+ bytes_transmitted += sum_sent_received_bytes(sizeof(struct
InquiryMessage), perf_store.inquery);
+ bytes_transmitted += sum_sent_received_bytes(sizeof(struct
GNUNET_MessageHeader), perf_store.demand);
+ bytes_transmitted += sum_sent_received_bytes(sizeof(struct
GNUNET_MessageHeader), perf_store.offer);
+ bytes_transmitted += sum_sent_received_bytes(4, perf_store.done);
-
- /*
+ /**
* Write IBF failure rate for different BUCKET_NUMBER_FACTOR
*/
float factor;
@@ -921,17 +954,28 @@ calculate_perf_rtt() {
int decoded = 0;
- if(perf_rtt.active_passive_switches == 0)
+ if(perf_store.active_passive_switches == 0)
decoded = 1;
- int ibf_bytes_transmitted = sum_sent_received_bytes(sizeof(struct
IBFMessage), perf_rtt.ibf);
+ int ibf_bytes_transmitted = sum_sent_received_bytes(sizeof(struct
IBFMessage), perf_store.ibf);
- FILE *out1 = fopen("perf_failure_bucket_number_factor.csv", "a");
- fprintf(out1,
"%d,%f,%d,%d,%f,%d,%d,%d,%d,%d\n",num_per_bucket,factor,decoded,ibf_bytes_transmitted,rtt,perf_rtt.se_diff,bytes_transmitted,perf_rtt.se_diff_local,perf_rtt.se_diff_remote,
perf_rtt.mode_of_operation);
+ FILE *out1 = fopen("perf_data.csv", "a");
+ fprintf(out1,
"%d,%f,%d,%d,%f,%d,%d,%d,%d,%d\n",num_per_bucket,factor,decoded,ibf_bytes_transmitted,rtt,perf_store.se_diff,bytes_transmitted,perf_store.se_diff_local,perf_store.se_diff_remote,
perf_store.mode_of_operation);
fclose(out1);
- return rtt;
}
-
+#endif
+/**
+ * Function that chooses the optimal mode of operation depending on
+ * operation parameters.
+ * @param avg_element_size
+ * @param local_set_size
+ * @param remote_set_size
+ * @param est_set_diff_remote
+ * @param est_set_diff_local
+ * @param bandwith_latency_tradeoff
+ * @param ibf_bucket_number_factor
+ * @return calcuated mode of operation
+ */
static uint8_t
estimate_best_mode_of_operation(uint64_t avg_element_size,
uint64_t local_set_size,
@@ -954,10 +998,10 @@ estimate_best_mode_of_operation(uint64_t avg_element_size,
* Calculate bytes for full Sync
*/
- uint8_t SIZEOF_FULL_DONE_HEADER = 4;
- uint8_t SIZEOF_DONE_HEADER = 4;
- uint8_t RTT_MIN_FULL = 2;
- uint8_t SIZEOF_REQUEST_FULL = 4;
+ uint8_t sizeof_full_done_header = 4;
+ uint8_t sizeof_done_header = 4;
+ uint8_t rtt_min_full = 2;
+ uint8_t sizeof_request_full = 4;
uint16_t estimated_total_diff = (est_set_diff_remote + est_set_diff_local);
/* Estimate byte required if we send first */
@@ -965,17 +1009,17 @@ estimate_best_mode_of_operation(uint64_t
avg_element_size,
uint64_t total_bytes_full_local_send_first = (avg_element_size *
total_elements_to_send_local_send_first) + \
(total_elements_to_send_local_send_first * sizeof(struct
GNUNET_SETU_ElementMessage)) + \
- (SIZEOF_FULL_DONE_HEADER * 2) + \
- RTT_MIN_FULL * bandwith_latency_tradeoff;
+ (sizeof_full_done_header * 2) + \
+ rtt_min_full * bandwith_latency_tradeoff;
/* Estimate bytes required if we request from remote peer */
uint64_t total_elements_to_send_remote_send_first = est_set_diff_local +
remote_set_size;
uint64_t total_bytes_full_remote_send_first = (avg_element_size *
total_elements_to_send_remote_send_first) + \
(total_elements_to_send_remote_send_first * sizeof(struct
GNUNET_SETU_ElementMessage)) + \
- (SIZEOF_FULL_DONE_HEADER * 2) + \
- (RTT_MIN_FULL + 0.5) * bandwith_latency_tradeoff + \
- SIZEOF_REQUEST_FULL;
+ (sizeof_full_done_header * 2) + \
+ (rtt_min_full + 0.5) * bandwith_latency_tradeoff + \
+ sizeof_request_full;
/*
* Calculate bytes for differential Sync
@@ -1004,7 +1048,7 @@ estimate_best_mode_of_operation(uint64_t avg_element_size,
/* Estimate full byte count for differential sync */
uint64_t element_size = (avg_element_size + sizeof(struct
GNUNET_SETU_ElementMessage)) * \
estimated_total_diff;
- uint64_t done_size = SIZEOF_DONE_HEADER;
+ uint64_t done_size = sizeof_done_header;
uint64_t inquery_size = (sizeof(struct IBF_Key) + sizeof(struct
InquiryMessage)) * estimated_total_diff;
uint64_t demand_size =
(sizeof(struct GNUNET_HashCode) + sizeof(struct
GNUNET_MessageHeader)) * estimated_total_diff;
@@ -1020,15 +1064,23 @@ estimate_best_mode_of_operation(uint64_t
avg_element_size,
if (full_min < total_bytes_diff) {
/* Decide between sending all element first or receiving all elements
*/
if (total_bytes_full_remote_send_first >
total_bytes_full_local_send_first) {
- return FULL_SYNC_LOCAL_SENDING_FIRST; //
FULL_SYNC_LOCAL_SENDING_FIRST;
+ return FULL_SYNC_LOCAL_SENDING_FIRST;
} else {
- return FULL_SYNC_REMOTE_SENDING_FIRST; //
FULL_SYNC_REMOTE_SENDING_FIRST;
+ return FULL_SYNC_REMOTE_SENDING_FIRST;
}
} else {
return DIFFERENTIAL_SYNC;
}
}
+/**
+ * Validates the if a message is received in a correct phase
+ * @param allowed_phases
+ * @param size_phases
+ * @param op
+ * @return GNUNET_YES if message permitted in phase and GNUNET_NO if not
permitted in given
+ * phase
+ */
static int check_valid_phase(uint8_t allowed_phases[], size_t size_phases,
struct Operation *op){
for(uint32_t phase_ctr=0; phase_ctr < size_phases; phase_ctr++) {
uint8_t phase = allowed_phases[phase_ctr];
@@ -1043,7 +1095,16 @@ static int check_valid_phase(uint8_t allowed_phases[],
size_t size_phases, struc
return GNUNET_NO;
}
-
+/**
+ * Function to update, track and validate message received in differential
+ * sync
+ * @param hash_map
+ * @param new_mcfs
+ * @param hash_code
+ * @param mt
+ * @return GNUNET_YES message is valid in message control flow GNUNET_NO when
message is not valid
+ * at this point in message flow
+ */
static int
update_message_control_flow(struct GNUNET_CONTAINER_MultiHashMap *hash_map,
enum MESSAGE_CONTROL_FLOW_STATE new_mcfs,
@@ -1085,6 +1146,13 @@ update_message_control_flow(struct
GNUNET_CONTAINER_MultiHashMap *hash_map,
return GNUNET_YES;
}
+/**
+ * Validate if a message in differential sync si already received before.
+ * @param hash_map
+ * @param hash_code
+ * @param mt
+ * @return GNUNET_YES when message is already in store if message is not in
store return GNUNET_NO
+ */
static int
is_message_in_message_control_flow(struct GNUNET_CONTAINER_MultiHashMap
*hash_map,
struct GNUNET_HashCode *hash_code,
@@ -1459,7 +1527,7 @@ fail_union_operation (struct Operation *op)
/**
- * Function that checks if full sync is plausible runnig
+ * Function that checks if full sync is plausible
* @param initial_local_elements_in_set
* @param estimated_set_difference
* @param repeated_elements
@@ -1513,11 +1581,11 @@ full_sync_plausibility_check (struct Operation *op) {
}
}
}
+
/**
* Limit active passive switches in differential sync to configured security
level
* @param op
*/
-
static void
check_max_differential_rounds(struct Operation *op)
{
@@ -1533,8 +1601,6 @@ check_max_differential_rounds(struct Operation *op)
}
}
-
-
/**
* Derive the IBF key from a hash code and
* a salt.
@@ -1563,12 +1629,12 @@ get_ibf_key (const struct GNUNET_HashCode *src)
struct GetElementContext
{
/**
- * FIXME.
+ * Gnunet hash code in context
*/
struct GNUNET_HashCode hash;
/**
- * FIXME.
+ * Pointer to the key enty
*/
struct KeyEntry *k;
};
@@ -1671,7 +1737,6 @@ op_register_element (struct Operation *op,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
}
-
/**
* Modify an IBF key @a k_in based on the @a salt, returning a
* salted key in @a k_out.
@@ -1691,7 +1756,7 @@ salt_key (const struct IBF_Key *k_in,
/**
- * FIXME.
+ * Reverse modification done in the salt_key function
*/
static void
unsalt_key (const struct IBF_Key *k_in,
@@ -1852,7 +1917,7 @@ send_ibf (struct Operation *op,
/**
* Enforce min size of IBF
*/
- uint32_t ibf_min_size = IBF_MIN_SIZE | 1;
+ uint32_t ibf_min_size = IBF_MIN_SIZE;
if(ibf_size < ibf_min_size) {
ibf_size=ibf_min_size;
@@ -1887,8 +1952,10 @@ send_ibf (struct Operation *op,
if (buckets_in_message > MAX_BUCKETS_PER_MESSAGE)
buckets_in_message = MAX_BUCKETS_PER_MESSAGE;
- perf_rtt.ibf.sent += 1;
- perf_rtt.ibf.sent_var_bytes += ( buckets_in_message * IBF_BUCKET_SIZE );
+ #if MEASURE_PERFORMANCE
+ perf_store.ibf.sent += 1;
+ perf_store.ibf.sent_var_bytes += ( buckets_in_message * IBF_BUCKET_SIZE );
+ #endif
ev = GNUNET_MQ_msg_extra (msg,
buckets_in_message * IBF_BUCKET_SIZE,
GNUNET_MESSAGE_TYPE_SETU_P2P_IBF);
@@ -1961,8 +2028,10 @@ send_full_element_iterator (void *cls,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Sending element %s\n",
GNUNET_h2s (key));
- perf_rtt.element_full.received += 1;
- perf_rtt.element_full.received_var_bytes += el->size;
+ #if MEASURE_PERFORMANCE
+ perf_store.element_full.received += 1;
+ perf_store.element_full.received_var_bytes += el->size;
+ #endif
ev = GNUNET_MQ_msg_extra (emsg,
el->size,
GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT);
@@ -2003,7 +2072,9 @@ send_full_set (struct Operation *op)
(void) GNUNET_CONTAINER_multihashmap_iterate
(op->set->content->elements_randomized,
&send_full_element_iterator,
op);
- perf_rtt.full_done.sent += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.full_done.sent += 1;
+ #endif
ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE);
GNUNET_MQ_send (op->mq,
ev);
@@ -2052,8 +2123,10 @@ static void
handle_union_p2p_strata_estimator (void *cls,
const struct StrataEstimatorMessage *msg)
{
- perf_rtt.se.received += 1;
- perf_rtt.se.received_var_bytes += ntohs (msg->header.size) - sizeof(struct
StrataEstimatorMessage);
+ #if MEASURE_PERFORMANCE
+ perf_store.se.received += 1;
+ perf_store.se.received_var_bytes += ntohs (msg->header.size) - sizeof(struct
StrataEstimatorMessage);
+ #endif
struct Operation *op = cls;
struct MultiStrataEstimator *remote_se;
unsigned int diff;
@@ -2064,8 +2137,6 @@ handle_union_p2p_strata_estimator (void *cls,
op->local_element_count = GNUNET_CONTAINER_multihashmap_size(
op->set->content->elements);
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "START OPERATION %u\n", op->peer_site);
// Setting peer site to receiving peer
op->peer_site = 1;
@@ -2165,22 +2236,12 @@ handle_union_p2p_strata_estimator (void *cls,
diff_remote = op->remote_element_count;
}
-
-
-
diff = diff_remote + diff_local;
op->remote_set_diff = diff_remote;
-
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "ESTIMATION IS total: %d remote:%d local: %d\n",
- diff,
- diff_remote,
- diff_local);
/** Calculate avg element size if not initial sync **/
uint64_t avg_element_size = 0;
- if(0 == op->number_elements_local) {
+ if(0 < op->number_elements_local) {
GNUNET_CONTAINER_multihashmap_iterate(op->set->content->elements,
&determinate_avg_element_size_iterator,
op);
@@ -2196,11 +2257,12 @@ handle_union_p2p_strata_estimator (void *cls,
op->rtt_bandwidth_tradeoff,
op->ibf_bucket_number_factor);
-
- perf_rtt.se_diff_local = diff_local;
- perf_rtt.se_diff_remote = diff_remote;
- perf_rtt.se_diff = diff;
- perf_rtt.mode_of_operation = op->mode_of_operation;
+ #if MEASURE_PERFORMANCE
+ perf_store.se_diff_local = diff_local;
+ perf_store.se_diff_remote = diff_remote;
+ perf_store.se_diff = diff;
+ perf_store.mode_of_operation = op->mode_of_operation;
+ #endif
strata_estimator_destroy (remote_se);
strata_estimator_destroy (op->se);
@@ -2243,14 +2305,13 @@ handle_union_p2p_strata_estimator (void *cls,
"# of full sends",
1,
GNUNET_NO);
- if ((op->mode_of_operation == FULL_SYNC_LOCAL_SENDING_FIRST) ||
- (0 == other_size))
+ if (FULL_SYNC_LOCAL_SENDING_FIRST == op->mode_of_operation )
{
struct TransmitFullMessage *signal_msg;
struct GNUNET_MQ_Envelope *ev;
ev = GNUNET_MQ_msg_extra(signal_msg,sizeof(struct
TransmitFullMessage),GNUNET_MESSAGE_TYPE_SETU_P2P_SEND_FULL);
signal_msg->remote_set_difference = htonl( diff_local);
- signal_msg->remote_set_size = htonl(op->number_elements_local);
+ signal_msg->remote_set_size = htonl(op->local_element_count);
signal_msg->local_set_difference = htonl(diff_remote);
GNUNET_MQ_send (op->mq,
ev);
@@ -2263,11 +2324,13 @@ handle_union_p2p_strata_estimator (void *cls,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Telling other peer that we expect its full set\n");
op->phase = PHASE_FULL_RECEIVING;
- perf_rtt.request_full.sent += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.request_full.sent += 1;
+ #endif
struct TransmitFullMessage *signal_msg;
ev = GNUNET_MQ_msg_extra(signal_msg,sizeof(struct
TransmitFullMessage),GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL);
signal_msg->remote_set_difference = htonl(diff_local);
- signal_msg->remote_set_size = htonl(op->number_elements_local);
+ signal_msg->remote_set_size = htonl(op->local_element_count);
signal_msg->local_set_difference = htonl(diff_remote);
GNUNET_MQ_send (op->mq,
ev);
@@ -2316,7 +2379,6 @@ send_offers_iterator (void *cls,
if (ke->ibf_key.key_val != sec->ibf_key.key_val)
return GNUNET_YES;
-
/* Prevent implementation from sending a offer multible times in case of
roll switch */
if (GNUNET_YES !=
is_message_in_message_control_flow(
@@ -2361,14 +2423,13 @@ send_offers_iterator (void *cls,
fail_union_operation (op);
return GNUNET_NO;
};
-
- perf_rtt.offer.sent += 1;
- perf_rtt.offer.sent_var_bytes += sizeof(struct GNUNET_HashCode);
-
+ #if MEASURE_PERFORMANCE
+ perf_store.offer.sent += 1;
+ perf_store.offer.sent_var_bytes += sizeof(struct GNUNET_HashCode);
+ #endif
ev = GNUNET_MQ_msg_header_extra (mh,
sizeof(struct GNUNET_HashCode),
GNUNET_MESSAGE_TYPE_SETU_P2P_OFFER);
-
GNUNET_assert (NULL != ev);
*(struct GNUNET_HashCode *) &mh[1] = ke->element->element_hash;
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2492,7 +2553,9 @@ decode_and_send (struct Operation *op)
"# of IBF retries",
1,
GNUNET_NO);
- perf_rtt.active_passive_switches += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.active_passive_switches += 1;
+ #endif
op->active_passive_switches += 1;
op->salt_send = op->salt_receive++;
@@ -2530,7 +2593,9 @@ decode_and_send (struct Operation *op)
LOG (GNUNET_ERROR_TYPE_DEBUG,
"transmitted all values, sending DONE\n");
- perf_rtt.done.sent += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.done.sent += 1;
+ #endif
ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_DONE);
GNUNET_MQ_send (op->mq, ev);
/* We now wait until we get a DONE message back
@@ -2552,8 +2617,10 @@ decode_and_send (struct Operation *op)
struct GNUNET_MQ_Envelope *ev;
struct InquiryMessage *msg;
- perf_rtt.inquery.sent += 1;
- perf_rtt.inquery.sent_var_bytes += sizeof(struct IBF_Key);
+ #if MEASURE_PERFORMANCE
+ perf_store.inquery.sent += 1;
+ perf_store.inquery.sent_var_bytes += sizeof(struct IBF_Key);
+ #endif
/** Add sent inquiries to hashmap for flow control **/
struct GNUNET_HashContext *hashed_key_context =
GNUNET_CRYPTO_hash_context_start ();
@@ -2593,6 +2660,12 @@ decode_and_send (struct Operation *op)
return GNUNET_OK;
}
+/**
+ * Check send full message received from other peer
+ * @param cls
+ * @param msg
+ * @return
+ */
static int
check_union_p2p_send_full (void *cls,
@@ -2601,6 +2674,12 @@ check_union_p2p_send_full (void *cls,
return GNUNET_OK;
}
+/**
+ * Handle send full message received from other peer
+ *
+ * @param cls
+ * @param msg
+ */
static void
handle_union_p2p_send_full (void *cls,
const struct TransmitFullMessage *msg)
@@ -2618,10 +2697,12 @@ handle_union_p2p_send_full (void *cls,
return;
}
+ /** write received values to operator**/
op->remote_element_count = ntohl(msg->remote_set_size);
op->remote_set_diff = ntohl(msg->remote_set_difference);
op->local_set_diff = ntohl(msg->local_set_difference);
+ /** Check byzantine limits **/
if(check_byzantine_bounds(op) != GNUNET_OK) {
LOG (GNUNET_ERROR_TYPE_ERROR,
"PROTOCOL VIOLATION: Parameters transmitted from other peer do
not satisfie byzantine "
@@ -2633,7 +2714,7 @@ handle_union_p2p_send_full (void *cls,
/** Calculate avg element size if not initial sync **/
uint64_t avg_element_size = 0;
- if(0 == op->number_elements_local) {
+ if(0 < op->number_elements_local) {
GNUNET_CONTAINER_multihashmap_iterate (op->set->content->elements,
&determinate_avg_element_size_iterator,
@@ -2641,6 +2722,7 @@ handle_union_p2p_send_full (void *cls,
avg_element_size = op->total_elements_size_local /
op->number_elements_local;
}
+ /** Validate mode of operation **/
int mode_of_operation = estimate_best_mode_of_operation(avg_element_size,
op->remote_element_count,
GNUNET_CONTAINER_multihashmap_size(
@@ -2649,7 +2731,6 @@ handle_union_p2p_send_full (void *cls,
op->local_set_diff,
op->rtt_bandwidth_tradeoff,
op->ibf_bucket_number_factor);
-
if(FULL_SYNC_LOCAL_SENDING_FIRST != mode_of_operation)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -2659,7 +2740,6 @@ handle_union_p2p_send_full (void *cls,
fail_union_operation (op);
return;
}
-
op->phase = PHASE_FULL_RECEIVING;
}
@@ -2723,7 +2803,6 @@ check_union_p2p_ibf (void *cls,
return GNUNET_OK;
}
-
/**
* Handle an IBF message from a remote peer.
*
@@ -2752,8 +2831,10 @@ handle_union_p2p_ibf (void *cls,
op->differential_sync_iterations++;
check_max_differential_rounds(op);
- perf_rtt.ibf.received += 1;
- perf_rtt.ibf.received_var_bytes += (ntohs (msg->header.size) - sizeof *msg);
+ #if MEASURE_PERFORMANCE
+ perf_store.ibf.received += 1;
+ perf_store.ibf.received_var_bytes += (ntohs (msg->header.size) - sizeof
*msg);
+ #endif
buckets_in_message = (ntohs (msg->header.size) - sizeof *msg)
/ IBF_BUCKET_SIZE;
@@ -2818,7 +2899,6 @@ handle_union_p2p_ibf (void *cls,
GNUNET_CADET_receive_done (op->channel);
}
-
/**
* Send a result message to the client indicating
* that there is a new element.
@@ -2860,7 +2940,6 @@ send_client_element (struct Operation *op,
ev);
}
-
/**
* Tests if the operation is finished, and if so notify.
*
@@ -2886,7 +2965,9 @@ maybe_finish (struct Operation *op)
struct GNUNET_MQ_Envelope *ev;
op->phase = PHASE_FINISHED;
- perf_rtt.done.sent += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.done.sent += 1;
+ #endif
ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_DONE);
GNUNET_MQ_send (op->mq,
ev);
@@ -2908,7 +2989,6 @@ maybe_finish (struct Operation *op)
}
}
-
/**
* Check an element message from a remote peer.
*
@@ -2958,11 +3038,12 @@ handle_union_p2p_elements (void *cls,
return;
}
-
element_size = ntohs (emsg->header.size) - sizeof(struct
GNUNET_SETU_ElementMessage);
- perf_rtt.element.received += 1;
- perf_rtt.element.received_var_bytes += element_size;
+ #if MEASURE_PERFORMANCE
+ perf_store.element.received += 1;
+ perf_store.element.received_var_bytes += element_size;
+ #endif
ee = GNUNET_malloc (sizeof(struct ElementEntry) + element_size);
GNUNET_memcpy (&ee[1],
@@ -3053,7 +3134,6 @@ handle_union_p2p_elements (void *cls,
maybe_finish (op);
}
-
/**
* Check a full element message from a remote peer.
*
@@ -3072,7 +3152,6 @@ check_union_p2p_full_element (void *cls,
return GNUNET_OK;
}
-
/**
* Handle an element message from a remote peer.
*
@@ -3102,8 +3181,10 @@ handle_union_p2p_full_element (void *cls,
element_size = ntohs (emsg->header.size)
- sizeof(struct GNUNET_SETU_ElementMessage);
- perf_rtt.element_full.received += 1;
- perf_rtt.element_full.received_var_bytes += element_size;
+ #if MEASURE_PERFORMANCE
+ perf_store.element_full.received += 1;
+ perf_store.element_full.received_var_bytes += element_size;
+ #endif
ee = GNUNET_malloc (sizeof(struct ElementEntry) + element_size);
GNUNET_memcpy (&ee[1], &emsg[1], element_size);
@@ -3168,7 +3249,6 @@ handle_union_p2p_full_element (void *cls,
GNUNET_CADET_receive_done (op->channel);
}
-
/**
* Send offers (for GNUNET_Hash-es) in response
* to inquiries (for IBF_Key-s).
@@ -3225,8 +3305,10 @@ handle_union_p2p_inquiry (void *cls,
return;
}
- perf_rtt.inquery.received += 1;
- perf_rtt.inquery.received_var_bytes += (ntohs (msg->header.size) -
sizeof(struct InquiryMessage));
+ #if MEASURE_PERFORMANCE
+ perf_store.inquery.received += 1;
+ perf_store.inquery.received_var_bytes += (ntohs (msg->header.size) -
sizeof(struct InquiryMessage));
+ #endif
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received union inquiry\n");
@@ -3286,7 +3368,9 @@ send_missing_full_elements_iter (void *cls,
if (GNUNET_YES == ke->received)
return GNUNET_YES;
- perf_rtt.element_full.received += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.element_full.received += 1;
+ #endif
ev = GNUNET_MQ_msg_extra (emsg,
ee->element.size,
GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT);
@@ -3344,14 +3428,16 @@ handle_union_p2p_request_full (void *cls,
return;
}
- perf_rtt.request_full.received += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.request_full.received += 1;
+ #endif
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received request for full set transmission\n");
/** Calculate avg element size if not initial sync **/
uint64_t avg_element_size = 0;
- if(0 == op->number_elements_local) {
+ if(0 < op->number_elements_local) {
GNUNET_CONTAINER_multihashmap_iterate (op->set->content->elements,
&determinate_avg_element_size_iterator,
op);
@@ -3406,7 +3492,9 @@ handle_union_p2p_full_done (void *cls,
return;
}
- perf_rtt.full_done.received += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.full_done.received += 1;
+ #endif
switch (op->phase)
{
@@ -3434,7 +3522,9 @@ handle_union_p2p_full_done (void *cls,
GNUNET_CONTAINER_multihashmap32_iterate (op->key_to_element,
&send_missing_full_elements_iter,
op);
- perf_rtt.full_done.sent += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.full_done.sent += 1;
+ #endif
ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE);
GNUNET_MQ_send (op->mq,
ev);
@@ -3523,9 +3613,10 @@ handle_union_p2p_demand (void *cls,
fail_union_operation (op);
return;
}
-
- perf_rtt.demand.received += 1;
- perf_rtt.demand.received_var_bytes += (ntohs (mh->size) - sizeof(struct
GNUNET_MessageHeader));
+ #if MEASURE_PERFORMANCE
+ perf_store.demand.received += 1;
+ perf_store.demand.received_var_bytes += (ntohs (mh->size) - sizeof(struct
GNUNET_MessageHeader));
+ #endif
num_hashes = (ntohs (mh->size) - sizeof(struct GNUNET_MessageHeader))
/ sizeof(struct GNUNET_HashCode);
@@ -3581,8 +3672,10 @@ handle_union_p2p_demand (void *cls,
fail_union_operation (op);
return;
}
- perf_rtt.element.sent += 1;
- perf_rtt.element.sent_var_bytes += ee->element.size;
+ #if MEASURE_PERFORMANCE
+ perf_store.element.sent += 1;
+ perf_store.element.sent_var_bytes += ee->element.size;
+ #endif
ev = GNUNET_MQ_msg_extra (emsg,
ee->element.size,
GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS);
@@ -3669,8 +3762,10 @@ handle_union_p2p_offer (void *cls,
return;
}
- perf_rtt.offer.received += 1;
- perf_rtt.offer.received_var_bytes += (ntohs (mh->size) - sizeof(struct
GNUNET_MessageHeader));
+ #if MEASURE_PERFORMANCE
+ perf_store.offer.received += 1;
+ perf_store.offer.received_var_bytes += (ntohs (mh->size) - sizeof(struct
GNUNET_MessageHeader));
+ #endif
num_hashes = (ntohs (mh->size) - sizeof(struct GNUNET_MessageHeader))
/ sizeof(struct GNUNET_HashCode);
@@ -3708,8 +3803,10 @@ handle_union_p2p_offer (void *cls,
"[OP %p] Requesting element (hash %s)\n",
op, GNUNET_h2s (hash));
- perf_rtt.demand.sent += 1;
- perf_rtt.demand.sent_var_bytes += sizeof(struct GNUNET_HashCode);
+ #if MEASURE_PERFORMANCE
+ perf_store.demand.sent += 1;
+ perf_store.demand.sent_var_bytes += sizeof(struct GNUNET_HashCode);
+ #endif
ev = GNUNET_MQ_msg_header_extra (demands,
sizeof(struct GNUNET_HashCode),
GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND);
@@ -3794,7 +3891,9 @@ handle_union_p2p_done (void *cls,
return;
}
- perf_rtt.done.received += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.done.received += 1;
+ #endif
switch (op->phase)
{
case PHASE_PASSIVE_DECODING:
@@ -3844,7 +3943,9 @@ static void
handle_union_p2p_over (void *cls,
const struct GNUNET_MessageHeader *mh)
{
- perf_rtt.over.received += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.over.received += 1;
+ #endif
send_client_done (cls);
}
@@ -4619,8 +4720,10 @@ handle_client_evaluate (void *cls,
op->message_control_flow =
GNUNET_CONTAINER_multihashmap_create(32,GNUNET_NO);
op->inquiries_sent = GNUNET_CONTAINER_multihashmap_create(32,GNUNET_NO);
+ #if MEASURE_PERFORMANCE
/* load config */
load_config(op);
+ #endif
/* Advance generation values, so that
mutations won't interfer with the running operation. */
@@ -4645,7 +4748,9 @@ handle_client_evaluate (void *cls,
struct GNUNET_MQ_Envelope *ev;
struct OperationRequestMessage *msg;
- perf_rtt.operation_request.sent += 1;
+ #if MEASURE_PERFORMANCE
+ perf_store.operation_request.sent += 1;
+ #endif
ev = GNUNET_MQ_msg_nested_mh (msg,
GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST,
context);
@@ -4818,8 +4923,10 @@ handle_client_accept (void *cls,
op->message_control_flow =
GNUNET_CONTAINER_multihashmap_create(32,GNUNET_NO);
op->inquiries_sent = GNUNET_CONTAINER_multihashmap_create(32,GNUNET_NO);
+ #if MEASURE_PERFORMANCE
/* load config */
load_config(op);
+ #endif
/* Advance generation values, so that future mutations do not
interfer with the running operation. */
@@ -4871,8 +4978,10 @@ handle_client_accept (void *cls,
SE_IBFS_TOTAL_SIZE,
se_count,
buf);
- perf_rtt.se.sent += 1;
- perf_rtt.se.sent_var_bytes += len;
+ #if MEASURE_PERFORMANCE
+ perf_store.se.sent += 1;
+ perf_store.se.sent_var_bytes += len;
+ #endif
if (len < se->stratas[0]->strata_count * IBF_BUCKET_SIZE *
SE_IBFS_TOTAL_SIZE)
type = GNUNET_MESSAGE_TYPE_SETU_P2P_SEC;
@@ -4923,7 +5032,9 @@ shutdown_task (void *cls)
GNUNET_YES);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"handled shutdown request\n");
- calculate_perf_rtt();
+ #if MEASURE_PERFORMANCE
+ calculate_perf_store();
+ #endif
}
diff --git a/src/setu/gnunet-service-setu_strata_estimator.c
b/src/setu/gnunet-service-setu_strata_estimator.c
index c8cecebea..29cfaf783 100644
--- a/src/setu/gnunet-service-setu_strata_estimator.c
+++ b/src/setu/gnunet-service-setu_strata_estimator.c
@@ -22,6 +22,7 @@
* @brief invertible bloom filter
* @author Florian Dold
* @author Christian Grothoff
+ * @author Elias Summermatter
*/
#include "platform.h"
#include "gnunet_util_lib.h"
diff --git a/src/setu/gnunet-service-setu_strata_estimator.h
b/src/setu/gnunet-service-setu_strata_estimator.h
index 51d06a73c..b25a15c74 100644
--- a/src/setu/gnunet-service-setu_strata_estimator.h
+++ b/src/setu/gnunet-service-setu_strata_estimator.h
@@ -22,6 +22,7 @@
* @file set/gnunet-service-setu_strata_estimator.h
* @brief estimator of set difference
* @author Florian Dold
+ * @author Elias Summermatter
*/
#ifndef GNUNET_SERVICE_SETU_STRATA_ESTIMATOR_H
diff --git a/src/setu/ibf.c b/src/setu/ibf.c
index 22145c652..f938d389d 100644
--- a/src/setu/ibf.c
+++ b/src/setu/ibf.c
@@ -22,6 +22,7 @@
* @file set/ibf.c
* @brief implementation of the invertible Bloom filter
* @author Florian Dold
+ * @author Elias Summermatter
*/
#include "ibf.h"
diff --git a/src/setu/ibf.h b/src/setu/ibf.h
index fcf52f7eb..5bd05d0c2 100644
--- a/src/setu/ibf.h
+++ b/src/setu/ibf.h
@@ -22,6 +22,7 @@
* @file set/ibf.h
* @brief invertible bloom filter
* @author Florian Dold
+ * @author Elias Summermatter
*/
#ifndef GNUNET_CONSENSUS_IBF_H
diff --git a/src/setu/perf_setu_api.c b/src/setu/perf_setu_api.c
index 22cac1257..599ad7b2c 100644
--- a/src/setu/perf_setu_api.c
+++ b/src/setu/perf_setu_api.c
@@ -22,6 +22,7 @@
* @file set/test_setu_api.c
* @brief testcase for setu_api.c
* @author Florian Dold
+ * @author Elias Summermatter
*/
#include "platform.h"
#include "gnunet_util_lib.h"
diff --git a/src/setu/setu_api.c b/src/setu/setu_api.c
index 304d3434d..006ec19db 100644
--- a/src/setu/setu_api.c
+++ b/src/setu/setu_api.c
@@ -22,6 +22,7 @@
* @brief api for the set union service
* @author Florian Dold
* @author Christian Grothoff
+ * @author Elias Summermatter
*/
#include "platform.h"
#include "gnunet_util_lib.h"
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 142/164: Maded struct camelcase, (continued)
- [gnunet] 142/164: Maded struct camelcase, gnunet, 2021/07/30
- [gnunet] 124/164: Fixed some bug, gnunet, 2021/07/30
- [gnunet] 144/164: Fixed mem leak, gnunet, 2021/07/30
- [gnunet] 133/164: Removed some unneseray padding from inquery message, gnunet, 2021/07/30
- [gnunet] 149/164: Restored normal config, gnunet, 2021/07/30
- [gnunet] 157/164: Fixed one more bug ;-), gnunet, 2021/07/30
- [gnunet] 158/164: removed exponation from plausability check, gnunet, 2021/07/30
- [gnunet] 162/164: Iproved ibf counter packing code, gnunet, 2021/07/30
- [gnunet] 127/164: Liniting, gnunet, 2021/07/30
- [gnunet] 125/164: Removed unusable counter, gnunet, 2021/07/30
- [gnunet] 122/164: Improved code and commtents,
gnunet <=
- [gnunet] 150/164: Fixed a bug in message controll, gnunet, 2021/07/30
- [gnunet] 145/164: Return early from function, gnunet, 2021/07/30
- [gnunet] 151/164: Fixed some bugs in implementation, gnunet, 2021/07/30
- [gnunet] 156/164: Added check to enforce active passive switch when inquiry colision occour, gnunet, 2021/07/30
- [gnunet] 155/164: Fixed implementaion, gnunet, 2021/07/30
- [gnunet] 115/164: Prepare fore messurement 1, gnunet, 2021/07/30
- [gnunet] 118/164: Prepare fore messurement 8, gnunet, 2021/07/30
- [gnunet] 141/164: Does this fix the mem leak, gnunet, 2021/07/30
- [gnunet] 114/164: Added probabilistic security check for full sync, gnunet, 2021/07/30
- [gnunet] 140/164: Fixed wrong place for null check, gnunet, 2021/07/30