37#define FAIL_10_1_COMPATIBILTIY 1
43#define MULTI_SE_BASE_COUNT 8
50#define AVG_BYTE_SIZE_SE 4221
61 uint64_t base_size = avg_element_size * element_count;
84 int s = (
salt * 7) % 64;
89 x = (x >> s) | (x << (64 - s));
102 int s = (
salt * 7) % 64;
105 x = (x << s) | (x >> (64 - s));
119 uint16_t se_ibf_total_size,
120 uint8_t number_se_send,
126 uint64_t sbuf_offset = 0;
127 se->
size = number_se_send;
130 for (uint8_t strata_ctr = 0; strata_ctr < number_se_send; strata_ctr++)
144#if FAIL_10_1_COMPATIBILTIY
179 uint8_t number_se_received,
180 uint16_t se_ibf_total_size,
190 osize = ((se_ibf_total_size / 8) * number_se_received) *
IBF_BUCKET_SIZE
205 * number_se_received)
213 for (uint8_t strata_ctr = 0; strata_ctr < number_se_received; strata_ctr++)
222 se->
size = number_se_received;
251 for (i = 0; v & 1; v >>= 1, i++)
273 for (
int strata_ctr = 0; strata_ctr < se->
size; strata_ctr++)
284 for (i = 0; v & 1; v >>= 1, i++)
309 uint8_t ibf_prime_sizes[] = {79,79,79,79,79,79,79,79};
324 for (i = 0; i < strata_count; i++)
327 ibf_prime_sizes[strata_ctr], ibf_hashnum);
331 "Failed to allocate memory for strata estimator\n");
332 for (j = 0; j < i; j++)
334 for (j = 0; j <= strata_ctr; j++)
362 int avg_local_diff = 0;
363 int avg_remote_diff = 0;
364 uint8_t number_of_estimators = se1->
size;
366 for (uint8_t strata_ctr = 0; strata_ctr < number_of_estimators; strata_ctr++)
384 for (
int ibf_count = 0;
GNUNET_YES; ibf_count++)
409 goto break_all_counting_loops;
414break_all_counting_loops:;
420 / number_of_estimators;
422 / number_of_estimators;
void ibf_subtract(struct InvertibleBloomFilter *ibf1, const struct InvertibleBloomFilter *ibf2)
Subtract ibf2 from ibf1, storing the result in ibf1.
int ibf_decode(struct InvertibleBloomFilter *ibf, int *ret_side, struct IBF_Key *ret_id)
Decode and remove an element from the IBF, if possible.
void ibf_read_slice(const void *buf, uint32_t start, uint32_t count, struct InvertibleBloomFilter *ibf)
Read buckets from a buffer into an ibf.
void ibf_write_slice(const struct InvertibleBloomFilter *ibf, uint32_t start, uint32_t count, void *buf)
Write buckets from an ibf to a buffer.
void ibf_insert(struct InvertibleBloomFilter *ibf, struct IBF_Key key)
Insert a key into an IBF.
struct InvertibleBloomFilter * ibf_dup(const struct InvertibleBloomFilter *ibf)
Create a copy of an IBF, the copy has to be destroyed properly.
struct InvertibleBloomFilter * ibf_create(uint32_t size, uint8_t hash_num)
Create an invertible bloom filter.
void ibf_remove(struct InvertibleBloomFilter *ibf, struct IBF_Key key)
Remove a key from an IBF.
void ibf_destroy(struct InvertibleBloomFilter *ibf)
Destroy all resources associated with the invertible bloom filter.
#define IBF_BUCKET_SIZE
Size of one ibf bucket in bytes.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
struct MultiStrataEstimator * strata_estimator_dup(struct MultiStrataEstimator *se)
Make a copy of a strata estimator.
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.
#define AVG_BYTE_SIZE_SE
The avg size of 1 se Based on the bsc thesis of Elias Summermatter (2021)
void strata_estimator_destroy(struct MultiStrataEstimator *se)
Destroy a strata estimator, free all of its resources.
uint8_t determine_strata_count(uint64_t avg_element_size, uint64_t element_count)
Calculates the optimal number of strata Estimators to send.
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.
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.
void strata_estimator_insert(struct MultiStrataEstimator *se, struct IBF_Key key)
Add a key to the strata estimator.
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.
void strata_estimator_difference(const struct MultiStrataEstimator *se1, const struct MultiStrataEstimator *se2)
Estimate set difference with two strata estimators, i.e.
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.
#define MULTI_SE_BASE_COUNT
Number of strata estimators in memory NOT transmitted.
void strata_estimator_remove(struct MultiStrataEstimator *se, struct IBF_Key key)
Remove a key from the strata estimator.
static unsigned int ibf_size
#define GNUNET_log(kind,...)
char * GNUNET_decompress(const char *input, size_t input_size, size_t output_size)
Decompress input, return the decompressed data as output.
int GNUNET_try_compression(const char *data, size_t old_size, char **result, size_t *new_size)
Try to compress the given block of data using libz.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
Keys that can be inserted into and removed from an IBF.
Invertible bloom filter (IBF).
int remote_decoded_count
If an IBF is decoded this count stores how many elements are on the remote site.
int local_decoded_count
If an IBF is decoded this count stores how many elements are on the local site.
uint32_t size
How many cells does this IBF have?
uint8_t size
Number of strata estimators in struct.
struct StrataEstimator ** stratas
Array of strata estimators.
A handle to a strata estimator.
unsigned int ibf_size
Size of each IBF stratum (in bytes)
struct InvertibleBloomFilter ** strata
The IBFs of this strata estimator.
unsigned int strata_count
Size of the IBF array in strata.