summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Summermatter <elias.summermatter@seccom.ch>2021-04-01 00:15:43 +0200
committerElias Summermatter <elias.summermatter@seccom.ch>2021-04-01 00:15:43 +0200
commit12bb6131739c483a8c633f137d4a8c51c441350f (patch)
tree6691de872cba39b70344774c6ba57826c012ddba
parentb26733024c73d991777b2a6546d1f7454aa9a33c (diff)
Setu fixed some bug in rand element gen and added variable payload for perfmance
-rw-r--r--src/setu/gnunet-service-setu.c13
-rw-r--r--src/setu/perf_setu_api.c10
-rw-r--r--src/setu/test_setu_api.c10
3 files changed, 21 insertions, 12 deletions
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index b3cbf6d0e..9d555aee3 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -643,7 +643,9 @@ static uint32_t suggest_id;
struct perf_num_send_resived_msg {
int sent;
+ int sent_var_bytes;
int received;
+ int received_var_bytes;
};
@@ -668,7 +670,10 @@ struct perf_rtt_struct perf_rtt;
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);
+ return (size * perf_rtt_struct.sent) +
+ (size * perf_rtt_struct.received) +
+ perf_rtt_struct.sent_var_bytes +
+ perf_rtt_struct.received_var_bytes;
}
static float
@@ -2089,9 +2094,12 @@ handle_union_p2p_elements (void *cls,
struct KeyEntry *ke;
uint16_t element_size;
- perf_rtt.element.received += 1;
+
element_size = ntohs (emsg->header.size) - sizeof(struct
GNUNET_SETU_ElementMessage);
+ perf_rtt.element.received += 1;
+ perf_rtt.element.received_var_bytes += element_size;
+
ee = GNUNET_malloc (sizeof(struct ElementEntry) + element_size);
GNUNET_memcpy (&ee[1],
&emsg[1],
@@ -2557,6 +2565,7 @@ handle_union_p2p_demand (void *cls,
return;
}
perf_rtt.element.sent += 1;
+ perf_rtt.element.sent_var_bytes += ee->element.size;
ev = GNUNET_MQ_msg_extra (emsg,
ee->element.size,
GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS);
diff --git a/src/setu/perf_setu_api.c b/src/setu/perf_setu_api.c
index 73b61c02a..60a5e5e85 100644
--- a/src/setu/perf_setu_api.c
+++ b/src/setu/perf_setu_api.c
@@ -212,7 +212,7 @@ init_set2 (void *cls)
unsigned char *gen_rdm_bytestream (size_t num_bytes)
{
unsigned char *stream = GNUNET_malloc (num_bytes);
- GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, stream, sizeof(stream));
+ GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, stream, num_bytes);
return stream;
}
@@ -229,7 +229,7 @@ initRandomSets(int overlap, int set1_size, int set2_size, int element_size_in_by
// Add elements to both sets
for (int i = 0; i < overlap; i++) {
element.data = gen_rdm_bytestream(element_size_in_bytes);
- element.size = strlen (element.data);
+ element.size = element_size_in_bytes;
GNUNET_SETU_add_element (set1, &element, NULL, NULL);
GNUNET_SETU_add_element (set2, &element, NULL, NULL);
set1_size--;
@@ -240,7 +240,7 @@ initRandomSets(int overlap, int set1_size, int set2_size, int element_size_in_by
// Add other elements to set 1
while(set1_size>0) {
element.data = gen_rdm_bytestream(element_size_in_bytes);
- element.size = strlen (element.data);
+ element.size = element_size_in_bytes;
GNUNET_SETU_add_element (set1, &element, NULL, NULL);
set1_size--;
}
@@ -249,7 +249,7 @@ initRandomSets(int overlap, int set1_size, int set2_size, int element_size_in_by
// Add other elements to set 2
while(set2_size > 0) {
element.data = gen_rdm_bytestream(element_size_in_bytes);
- element.size = strlen (element.data);
+ element.size = element_size_in_bytes;
if(set2_size != 1) {
GNUNET_SETU_add_element (set2, &element,NULL, NULL);
@@ -395,7 +395,7 @@ run (void *cls,
"Running real set-reconciliation\n");
//init_set1 ();
// limit ~23800 element total
- initRandomSets(88,100,90,32);
+ initRandomSets(99,100,100,64);
}
static void execute_perf()
diff --git a/src/setu/test_setu_api.c b/src/setu/test_setu_api.c
index d573cfe3c..d5c9f5b7a 100644
--- a/src/setu/test_setu_api.c
+++ b/src/setu/test_setu_api.c
@@ -210,8 +210,8 @@ init_set2 (void *cls)
unsigned char *gen_rdm_bytestream (size_t num_bytes)
{
- unsigned char *stream = GNUNET_malloc (num_bytes + 1);
- GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, stream, num_bytes - 1);
+ unsigned char *stream = GNUNET_malloc (num_bytes);
+ GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, stream, num_bytes);
return stream;
}
@@ -228,7 +228,7 @@ initRandomSets(int overlap, int set1_size, int set2_size, int element_size_in_by
// Add elements to both sets
for (int i = 0; i < overlap; i++) {
element.data = gen_rdm_bytestream(element_size_in_bytes);
- element.size = strlen (element.data);
+ element.size = element_size_in_bytes;
GNUNET_SETU_add_element (set1, &element, NULL, NULL);
GNUNET_SETU_add_element (set2, &element, NULL, NULL);
set1_size--;
@@ -239,7 +239,7 @@ initRandomSets(int overlap, int set1_size, int set2_size, int element_size_in_by
// Add other elements to set 1
while(set1_size>0) {
element.data = gen_rdm_bytestream(element_size_in_bytes);
- element.size = strlen (element.data);
+ element.size = element_size_in_bytes;
GNUNET_SETU_add_element (set1, &element, NULL, NULL);
set1_size--;
}
@@ -248,7 +248,7 @@ initRandomSets(int overlap, int set1_size, int set2_size, int element_size_in_by
// Add other elements to set 2
while(set2_size > 0) {
element.data = gen_rdm_bytestream(element_size_in_bytes);
- element.size = strlen (element.data);
+ element.size = element_size_in_bytes;
if(set2_size != 1) {
GNUNET_SETU_add_element (set2, &element,NULL, NULL);