[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 74/164: Add new algo to determinate mode of operation
From: |
gnunet |
Subject: |
[gnunet] 74/164: Add new algo to determinate mode of operation |
Date: |
Fri, 30 Jul 2021 15:32:20 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 0cc9621567cdc8e441108fc5c803983384d8c687
Author: Elias Summermatter <elias.summermatter@seccom.ch>
AuthorDate: Wed May 5 14:00:00 2021 +0200
Add new algo to determinate mode of operation
---
src/setu/gnunet-service-setu.c | 121 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 118 insertions(+), 3 deletions(-)
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index 3475220e7..fdd0ee117 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -78,12 +78,23 @@
*/
#define IBF_ALPHA 4
+/**
+ * Calculate min of two given Values
+ */
+
+#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
+
/**
* Minimal size of an ibf
*/
#define IBF_MIN_SIZE 36
+/**
+ * AVG RTT for differential sync when k=2 and Factor = 2
+ */
+#define DIFFERENTIAL_RTT_MEAN 3.65145
+
/**
* Current phase we are in for a union operation.
@@ -153,6 +164,14 @@ enum UnionOperationPhase
};
+enum MODE_OF_OPERATION
+{
+ DIFFERENTIAL_SYNC,
+ FULL_SYNC_LOCAL_SENDING_FIRST,
+ FULL_SYNC_REMOTE_SENDING_FIRST
+};
+
+
/**
* Information about an element element in the set. All elements are
* stored in a hash-table from their hash-code to their `struct
@@ -854,6 +873,91 @@ calculate_perf_rtt() {
return rtt;
}
+static uint8_t
+estimate_best_mode_of_operation(uint64_t avg_element_size,
+ uint64_t local_set_size,
+ uint64_t remote_set_size,
+ uint64_t est_set_diff_remote,
+ uint64_t est_set_diff_local,
+ uint64_t bandwith_latency_tradeoff,
+ uint64_t ibf_bucket_number_factor)
+{
+ /*
+ * 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;
+ uint16_t estimated_total_diff = (est_set_diff_remote + est_set_diff_local);
+
+ /* Estimate byte required if we send first */
+ uint64_t total_elements_to_send_local_send_first = local_set_size +
est_set_diff_remote;
+
+ 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;
+
+ /* 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;
+
+ /*
+ * Calculate bytes for differential Sync
+ */
+
+ /* Estimate bytes required by IBF transmission*/
+
+ double ibf_bucket_count = estimated_total_diff * ibf_bucket_number_factor;
+
+ if (ibf_bucket_count <= IBF_MIN_SIZE) {
+ ibf_bucket_count = IBF_MIN_SIZE;
+ }
+
+ uint64_t ibf_message_count = ceil((float) ibf_bucket_count /
MAX_BUCKETS_PER_MESSAGE);
+
+ uint64_t estimated_counter_size = ceil(MIN(2 *
log2l((float)local_set_size/ibf_bucket_count), log2l(local_set_size)));
+
+ float counter_bytes = (float) estimated_counter_size / 8;
+
+ uint64_t ibf_bytes = ceil((sizeof(struct IBFMessage) * ibf_message_count)
* 1.2 + \
+ (ibf_bucket_count * sizeof(struct IBF_Key)) * 1.2 + \
+ (ibf_bucket_count * sizeof(struct IBF_KeyHash)) * 1.2 + \
+ (ibf_bucket_count * counter_bytes) * 1.2);
+
+ /* 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 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;
+ uint64_t offer_size = (sizeof(struct GNUNET_HashCode) + sizeof(struct
GNUNET_MessageHeader)) * estimated_total_diff;
+
+ uint64_t total_bytes_diff = (element_size + done_size + inquery_size +
demand_size + offer_size + ibf_bytes) + \
+ ( DIFFERENTIAL_RTT_MEAN *
bandwith_latency_tradeoff );
+
+ uint64_t full_min = MIN(total_elements_to_send_local_send_first,
total_elements_to_send_remote_send_first);
+
+ /* Decide between full and differential sync */
+ 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;
+ } else {
+ return FULL_SYNC_REMOTE_SENDING_FIRST;
+ }
+ } else {
+ return DIFFERENTIAL_SYNC;
+ }
+}
+
/**
* Iterator over hash map entries, called to
@@ -1661,13 +1765,24 @@ handle_union_p2p_strata_estimator (void *cls,
int remote_elements_decoded = remote_se->strata[0]->remote_decoded_count;
int local_elements_decoded = remote_se->strata[0]->local_decoded_count;
- int total_decoded = remote_elements_decoded + local_elements_decoded;
- int diff_remote = ((float)remote_elements_decoded / (float)total_decoded) *
diff;
- int diff_local = ((float)local_elements_decoded / (float)total_decoded) *
diff;
+ uint64_t total_decoded = remote_elements_decoded + local_elements_decoded;
+ uint64_t diff_remote = ((float)remote_elements_decoded /
(float)total_decoded) * diff;
+ uint64_t diff_local = ((float)local_elements_decoded / (float)total_decoded)
* diff;
perf_rtt.se_diff_local = diff_local;
perf_rtt.se_diff_remote = diff_remote;
perf_rtt.se_diff = diff;
+
+ uint8_t mode_of_operation = estimate_best_mode_of_operation(32,
+
op->local_element_count,
+
op->remote_element_count,
+ diff_local,
+ diff_remote,
+
op->rtt_bandwidth_tradeoff,
+
op->ibf_bucket_number_factor);
+
+
+
/**
if (diff > 200)
diff = diff * 3 / 2;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 48/164: Test data 500 elements, (continued)
- [gnunet] 48/164: Test data 500 elements, gnunet, 2021/07/30
- [gnunet] 59/164: Simulation, gnunet, 2021/07/30
- [gnunet] 49/164: Added MIN IBF Size auto increase depended on totalsetsize + added missing remote/local element count to op, gnunet, 2021/07/30
- [gnunet] 51/164: Extended look, gnunet, 2021/07/30
- [gnunet] 52/164: Try something, gnunet, 2021/07/30
- [gnunet] 61/164: Simulation, gnunet, 2021/07/30
- [gnunet] 73/164: Performance chech, gnunet, 2021/07/30
- [gnunet] 85/164: Perf test, gnunet, 2021/07/30
- [gnunet] 89/164: Perftest, gnunet, 2021/07/30
- [gnunet] 75/164: Final messurement, gnunet, 2021/07/30
- [gnunet] 74/164: Add new algo to determinate mode of operation,
gnunet <=
- [gnunet] 95/164: Perftest, gnunet, 2021/07/30
- [gnunet] 98/164: Perftest, gnunet, 2021/07/30
- [gnunet] 101/164: Added element avg calculation, gnunet, 2021/07/30
- [gnunet] 77/164: Added new algo to determine operation mode, gnunet, 2021/07/30
- [gnunet] 81/164: Perf test, gnunet, 2021/07/30
- [gnunet] 87/164: Perf test, gnunet, 2021/07/30
- [gnunet] 100/164: Added message flow control, gnunet, 2021/07/30
- [gnunet] 108/164: Added some more sec checks, gnunet, 2021/07/30
- [gnunet] 93/164: Perftest, gnunet, 2021/07/30
- [gnunet] 94/164: Perftest, gnunet, 2021/07/30