#include "platform.h"
#include "gnunet_util_lib.h"
#include "ibf.h"
#include "gnunet-service-setu_strata_estimator.h"
Go to the source code of this file.
Macros | |
#define | FAIL_10_1_COMPATIBILTIY 1 |
Should we try compressing the strata estimator? This will break compatibility with the 0.10.1-network. More... | |
#define | MULTI_SE_BASE_COUNT 8 |
Number of strata estimators in memory NOT transmitted. More... | |
#define | AVG_BYTE_SIZE_SE 4221 |
The avg size of 1 se Based on the bsc thesis of Elias Summermatter (2021) More... | |
Functions | |
uint8_t | determine_strata_count (uint64_t avg_element_size, uint64_t element_count) |
Calculates the optimal number of strata Estimators to send. More... | |
static void | salt_key (const struct IBF_Key *k_in, uint32_t salt, struct IBF_Key *k_out) |
Modify an IBF key k_in based on the salt, returning a salted key in k_out. More... | |
static void | unsalt_key (const struct IBF_Key *k_in, uint32_t salt, struct IBF_Key *k_out) |
Reverse modification done in the salt_key function. More... | |
size_t | strata_estimator_write (struct MultiStrataEstimator *se, uint16_t se_ibf_total_size, uint8_t number_se_send, void *buf) |
Write the given strata estimator to the buffer. More... | |
int | strata_estimator_read (const void *buf, size_t buf_len, int is_compressed, uint8_t number_se_received, uint16_t se_ibf_total_size, struct MultiStrataEstimator *se) |
Read strata from the buffer into the given strata estimator. More... | |
void | strata_estimator_insert (struct MultiStrataEstimator *se, struct IBF_Key key) |
Add a key to the strata estimator. More... | |
void | strata_estimator_remove (struct MultiStrataEstimator *se, struct IBF_Key key) |
Remove a key from the strata estimator. More... | |
struct MultiStrataEstimator * | strata_estimator_create (unsigned int strata_count, uint32_t ibf_size, uint8_t ibf_hashnum) |
Create a new strata estimator with the given parameters. More... | |
void | strata_estimator_difference (const struct MultiStrataEstimator *se1, const struct MultiStrataEstimator *se2) |
Estimate set difference with two strata estimators, i.e. More... | |
struct MultiStrataEstimator * | strata_estimator_dup (struct MultiStrataEstimator *se) |
Make a copy of a strata estimator. More... | |
void | strata_estimator_destroy (struct MultiStrataEstimator *se) |
Destroy a strata estimator, free all of its resources. More... | |
#define FAIL_10_1_COMPATIBILTIY 1 |
Should we try compressing the strata estimator? This will break compatibility with the 0.10.1-network.
Definition at line 37 of file gnunet-service-setu_strata_estimator.c.
#define MULTI_SE_BASE_COUNT 8 |
Number of strata estimators in memory NOT transmitted.
Definition at line 43 of file gnunet-service-setu_strata_estimator.c.
#define AVG_BYTE_SIZE_SE 4221 |
The avg size of 1 se Based on the bsc thesis of Elias Summermatter (2021)
Definition at line 50 of file gnunet-service-setu_strata_estimator.c.
uint8_t determine_strata_count | ( | uint64_t | avg_element_size, |
uint64_t | element_count | ||
) |
Calculates the optimal number of strata Estimators to send.
Deteminate how many strata estimators in the message are necessary.
avg_element_size | |
element_count |
Definition at line 59 of file gnunet-service-setu_strata_estimator.c.
References AVG_BYTE_SIZE_SE.
Referenced by handle_client_accept().
Modify an IBF key k_in based on the salt, returning a salted key in k_out.
Definition at line 80 of file gnunet-service-setu_strata_estimator.c.
References IBF_Key::key_val, and salt.
Referenced by strata_estimator_insert().
|
static |
Reverse modification done in the salt_key function.
Definition at line 98 of file gnunet-service-setu_strata_estimator.c.
References IBF_Key::key_val, and salt.
Referenced by strata_estimator_remove().
size_t strata_estimator_write | ( | struct MultiStrataEstimator * | se, |
uint16_t | se_ibf_total_size, | ||
uint8_t | number_se_send, | ||
void * | buf | ||
) |
Write the given strata estimator to the buffer.
se | strata estimator to serialize | |
[out] | buf | buffer to write to, must be of appropriate size |
Definition at line 118 of file gnunet-service-setu_strata_estimator.c.
References GNUNET_assert, GNUNET_free, GNUNET_memcpy, GNUNET_try_compression(), GNUNET_YES, IBF_BUCKET_SIZE, StrataEstimator::ibf_size, ibf_write_slice(), MultiStrataEstimator::size, StrataEstimator::strata, StrataEstimator::strata_count, and MultiStrataEstimator::stratas.
int strata_estimator_read | ( | const void * | buf, |
size_t | buf_len, | ||
int | is_compressed, | ||
uint8_t | number_se_received, | ||
uint16_t | se_ibf_total_size, | ||
struct MultiStrataEstimator * | se | ||
) |
Read strata from the buffer into the given strata estimator.
The strata estimator must already be allocated.
buf | buffer to read from | |
buf_len | number of bytes in buf | |
is_compressed | is the data compressed? | |
[out] | se | strata estimator to write to |
Definition at line 176 of file gnunet-service-setu_strata_estimator.c.
References GNUNET_break, GNUNET_break_op, GNUNET_decompress(), GNUNET_free, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, IBF_BUCKET_SIZE, ibf_read_slice(), StrataEstimator::ibf_size, MultiStrataEstimator::size, StrataEstimator::strata, StrataEstimator::strata_count, and MultiStrataEstimator::stratas.
void strata_estimator_insert | ( | struct MultiStrataEstimator * | se, |
struct IBF_Key | key | ||
) |
Add a key to the strata estimator.
se | strata estimator to add the key to |
key | key to add |
Definition at line 235 of file gnunet-service-setu_strata_estimator.c.
References ibf_insert(), key, IBF_Key::key_val, MULTI_SE_BASE_COUNT, salt_key(), StrataEstimator::strata, and MultiStrataEstimator::stratas.
void strata_estimator_remove | ( | struct MultiStrataEstimator * | se, |
struct IBF_Key | key | ||
) |
Remove a key from the strata estimator.
(NOT USED)
se | strata estimator to remove the key from |
key | key to remove |
Definition at line 268 of file gnunet-service-setu_strata_estimator.c.
References ibf_remove(), key, IBF_Key::key_val, MULTI_SE_BASE_COUNT, MultiStrataEstimator::size, StrataEstimator::strata, MultiStrataEstimator::stratas, and unsalt_key().
struct MultiStrataEstimator * strata_estimator_create | ( | unsigned int | strata_count, |
uint32_t | ibf_size, | ||
uint8_t | ibf_hashnum | ||
) |
Create a new strata estimator with the given parameters.
strata_count | number of stratas, that is, number of ibfs in the estimator |
ibf_size | size of each ibf stratum |
ibf_hashnum | hashnum parameter of each ibf |
Definition at line 302 of file gnunet-service-setu_strata_estimator.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_new_array, ibf_create(), ibf_destroy(), StrataEstimator::ibf_size, MULTI_SE_BASE_COUNT, MultiStrataEstimator::size, StrataEstimator::strata, StrataEstimator::strata_count, and MultiStrataEstimator::stratas.
void strata_estimator_difference | ( | const struct MultiStrataEstimator * | se1, |
const struct MultiStrataEstimator * | se2 | ||
) |
Estimate set difference with two strata estimators, i.e.
Get an estimation of the symmetric difference of the elements contained in both strata estimators.
arrays of IBFs. Does not not modify its arguments.
se1 | first strata estimator |
se2 | second strata estimator |
Definition at line 359 of file gnunet-service-setu_strata_estimator.c.
References GNUNET_assert, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, ibf_decode(), ibf_destroy(), ibf_dup(), ibf_subtract(), InvertibleBloomFilter::local_decoded_count, InvertibleBloomFilter::remote_decoded_count, InvertibleBloomFilter::size, MultiStrataEstimator::size, StrataEstimator::strata, StrataEstimator::strata_count, and MultiStrataEstimator::stratas.
struct MultiStrataEstimator * strata_estimator_dup | ( | struct MultiStrataEstimator * | se | ) |
Make a copy of a strata estimator.
se | the strata estimator to copy |
Definition at line 433 of file gnunet-service-setu_strata_estimator.c.
References GNUNET_new, GNUNET_new_array, ibf_dup(), StrataEstimator::ibf_size, MULTI_SE_BASE_COUNT, StrataEstimator::strata, StrataEstimator::strata_count, and MultiStrataEstimator::stratas.
void strata_estimator_destroy | ( | struct MultiStrataEstimator * | se | ) |
Destroy a strata estimator, free all of its resources.
se | strata estimator to destroy. |
Definition at line 464 of file gnunet-service-setu_strata_estimator.c.
References GNUNET_free, ibf_destroy(), MULTI_SE_BASE_COUNT, StrataEstimator::strata, StrataEstimator::strata_count, and MultiStrataEstimator::stratas.