41 #define LOG(kind, ...) GNUNET_log_from (kind, "setu", __VA_ARGS__)
47 #define INCOMING_CHANNEL_TIMEOUT GNUNET_TIME_UNIT_MINUTES
52 #define SE_STRATA_COUNT 32
59 #define SE_IBFS_TOTAL_SIZE 632
64 #define SE_IBF_HASH_NUM 3
69 #define MAX_BUCKETS_PER_MESSAGE ((1 << 16) / IBF_BUCKET_SIZE)
76 #define MAX_IBF_SIZE 1048576
83 #define IBF_MIN_SIZE 37
89 #define DIFFERENTIAL_RTT_MEAN 3.65145
95 #define SECURITY_LEVEL 80
102 #define PROBABILITY_FOR_NEW_ROUND 0.15
108 #define MEASURE_PERFORMANCE 0
761 #if MEASURE_PERFORMANCE
774 struct perf_num_send_received_msg
777 uint64_t sent_var_bytes;
779 uint64_t received_var_bytes;
785 struct per_store_struct
787 struct perf_num_send_received_msg operation_request;
788 struct perf_num_send_received_msg se;
789 struct perf_num_send_received_msg request_full;
790 struct perf_num_send_received_msg element_full;
791 struct perf_num_send_received_msg full_done;
792 struct perf_num_send_received_msg ibf;
793 struct perf_num_send_received_msg inquery;
794 struct perf_num_send_received_msg element;
795 struct perf_num_send_received_msg demand;
796 struct perf_num_send_received_msg offer;
797 struct perf_num_send_received_msg
done;
798 struct perf_num_send_received_msg over;
800 uint64_t se_diff_remote;
801 uint64_t se_diff_local;
802 uint64_t active_passive_switches;
803 uint8_t mode_of_operation;
806 struct per_store_struct perf_store;
879 #if MEASURE_PERFORMANCE
897 "BUCKET_NUMBER_FACTOR",
899 op->ibf_bucket_number_factor = fl;
904 op->ibf_number_buckets_per_element =
number;
909 op->rtt_bandwidth_tradeoff =
number;
926 sum_sent_received_bytes (uint64_t
size,
927 struct perf_num_send_received_msg
928 perf_num_send_received_msg)
930 return (
size * perf_num_send_received_msg.sent)
931 + (
size * perf_num_send_received_msg.received)
932 + perf_num_send_received_msg.sent_var_bytes
933 + perf_num_send_received_msg.received_var_bytes;
941 calculate_perf_store ()
948 int bytes_transmitted = 0;
953 if ((perf_store.element_full.received != 0) ||
954 (perf_store.element_full.sent != 0)
958 if ((perf_store.request_full.received != 0) ||
959 (perf_store.request_full.sent != 0)
967 if ((perf_store.element.received != 0) ||
968 (perf_store.element.sent != 0))
970 int iterations = perf_store.active_passive_switches;
973 rtt += iterations * 0.5;
981 bytes_transmitted += sum_sent_received_bytes (
sizeof(
struct
983 perf_store.request_full);
985 bytes_transmitted += sum_sent_received_bytes (
sizeof(
struct
987 perf_store.element_full);
988 bytes_transmitted += sum_sent_received_bytes (
sizeof(
struct
992 bytes_transmitted += sum_sent_received_bytes (
sizeof(
struct
995 bytes_transmitted += sum_sent_received_bytes (4, perf_store.full_done);
996 bytes_transmitted += sum_sent_received_bytes (
sizeof(
struct IBFMessage),
998 bytes_transmitted += sum_sent_received_bytes (
sizeof(
struct InquiryMessage),
1000 bytes_transmitted += sum_sent_received_bytes (
sizeof(
struct
1003 bytes_transmitted += sum_sent_received_bytes (
sizeof(
struct
1006 bytes_transmitted += sum_sent_received_bytes (4, perf_store.done);
1014 long long num_per_bucket;
1020 if (perf_store.active_passive_switches == 0)
1022 int ibf_bytes_transmitted = sum_sent_received_bytes (
sizeof(
struct
1026 FILE *out1 = fopen (
"perf_data.csv",
"a");
1027 fprintf (out1,
"%d,%f,%d,%d,%f,%d,%d,%d,%d,%d\n",num_per_bucket,factor,
1028 decoded,ibf_bytes_transmitted,rtt,perf_store.se_diff,
1030 perf_store.se_diff_local,perf_store.se_diff_remote,
1031 perf_store.mode_of_operation);
1052 uint64_t local_set_size,
1053 uint64_t remote_set_size,
1054 uint64_t est_set_diff_remote,
1055 uint64_t est_set_diff_local,
1056 uint64_t bandwith_latency_tradeoff,
1057 uint64_t ibf_bucket_number_factor)
1064 if (0 == local_set_size)
1066 if (0 == remote_set_size)
1073 uint8_t sizeof_full_done_header = 4;
1074 uint8_t sizeof_done_header = 4;
1075 uint8_t rtt_min_full = 2;
1076 uint8_t sizeof_request_full = 4;
1077 uint64_t estimated_total_diff = (est_set_diff_remote + est_set_diff_local);
1080 uint64_t total_elements_to_send_local_send_first = est_set_diff_remote
1083 uint64_t total_bytes_full_local_send_first = (avg_element_size
1085 total_elements_to_send_local_send_first) \
1087 total_elements_to_send_local_send_first *
sizeof(
struct
1089 + (sizeof_full_done_header * 2) \
1091 * bandwith_latency_tradeoff;
1094 uint64_t total_elements_to_send_remote_send_first = est_set_diff_local
1097 uint64_t total_bytes_full_remote_send_first = (avg_element_size
1099 total_elements_to_send_remote_send_first) \
1101 total_elements_to_send_remote_send_first *
sizeof(
struct
1103 + (sizeof_full_done_header * 2) \
1104 + (rtt_min_full + 0.5)
1105 * bandwith_latency_tradeoff \
1106 + sizeof_request_full;
1114 long double ibf_bucket_count = estimated_total_diff
1115 * ibf_bucket_number_factor;
1121 uint64_t ibf_message_count = ceil ( ((
float) ibf_bucket_count)
1124 uint64_t estimated_counter_size = ceil (
1125 MIN (2 * log2l (((
float) local_set_size)
1126 / ((
float) ibf_bucket_count)),
1127 log2l (local_set_size)));
1129 long double counter_bytes = (float) estimated_counter_size / 8;
1131 uint64_t ibf_bytes = ceil ((
sizeof (
struct IBFMessage) * ibf_message_count)
1133 + (ibf_bucket_count *
sizeof(
struct IBF_Key)) * 1.2 \
1136 + (ibf_bucket_count * counter_bytes) * 1.2);
1141 * estimated_total_diff;
1142 uint64_t done_size = sizeof_done_header;
1143 uint64_t inquery_size = (
sizeof (
struct IBF_Key)
1145 * estimated_total_diff;
1146 uint64_t demand_size =
1148 * estimated_total_diff;
1151 * estimated_total_diff;
1153 uint64_t total_bytes_diff = (
element_size + done_size + inquery_size
1154 + demand_size + offer_size + ibf_bytes) \
1156 * bandwith_latency_tradeoff);
1158 uint64_t full_min = MIN (total_bytes_full_local_send_first,
1159 total_bytes_full_remote_send_first);
1163 if (full_min < total_bytes_diff)
1166 if (total_bytes_full_remote_send_first > total_bytes_full_local_send_first)
1198 for (uint32_t phase_ctr = 0; phase_ctr < size_phases; phase_ctr++)
1200 uint8_t
phase = allowed_phases[phase_ctr];
1204 "Message received in valid phase\n");
1209 "Received message in invalid phase: %u\n",
op->phase);
1244 "Received an element without sent offer!\n");
1252 "Received an element that was not demanded\n");
1298 if (new_mcfs <= *mcfs)
1402 op->total_elements_size_local += element->
size;
1434 &
op->set->content->elements_randomized_salt,
1491 "Union operation failed\n");
1493 "# Union operations failed",
1508 "# Union operations succeeded",
1512 "Signalling client that union operation is done\n");
1519 op->key_to_element));
1540 if (
op->remote_element_count +
op->remote_set_diff >
1541 op->byzantine_upper_bound)
1543 if (
op->local_element_count +
op->local_set_diff >
op->byzantine_upper_bound)
1549 if (
op->remote_element_count <
op->byzantine_lower_bound)
1582 struct Set *set =
op->set;
1586 "Destroying union operation %p\n",
1590 if (NULL !=
op->remote_ibf)
1593 op->remote_ibf = NULL;
1595 if (NULL !=
op->demanded_hashes)
1598 op->demanded_hashes = NULL;
1600 if (NULL !=
op->local_ibf)
1603 op->local_ibf = NULL;
1610 if (NULL !=
op->key_to_element)
1616 op->key_to_element = NULL;
1618 if (NULL !=
op->message_control_flow)
1624 op->message_control_flow = NULL;
1626 if (NULL !=
op->inquiries_sent)
1629 op->inquiries_sent = NULL;
1638 if (NULL !=
op->context_msg)
1641 op->context_msg = NULL;
1643 if (NULL != (channel =
op->channel))
1675 "Destroying incoming operation %p\n",
1677 if (NULL != (listener =
op->listener))
1682 op->listener = NULL;
1684 if (NULL !=
op->timeout_task)
1687 op->timeout_task = NULL;
1703 if (NULL != (channel =
op->channel))
1710 if (NULL !=
op->listener)
1715 if (NULL !=
op->set)
1735 "union operation failed\n");
1738 msg->request_id = htonl (
op->client_request_id);
1739 msg->element_type = htons (0);
1763 uint64_t duplicates =
op->received_fresh -
op->received_total;
1773 "PROTOCOL VIOLATION: Received duplicate element in full receiving "
1774 "mode of operation this is not allowed! Duplicates: %llu\n",
1775 (
unsigned long long) duplicates);
1788 if (0 ==
op->remote_set_diff)
1789 op->remote_set_diff = 1;
1791 long double base = (1 - (
long double) (
op->remote_set_diff
1792 / (
long double) (
op->initial_size
1795 long double exponent = (
op->received_total - (
op->received_fresh * ((
long
1803 long double value = exponent * (log2l (base) / log2l (2));
1807 "PROTOCOL VIOLATION: Other peer violated probabilistic rule for receiving "
1808 "to many duplicated full element : %LF\n",
1825 double probability =
op->differential_sync_iterations * (log2l (
1831 "PROTOCOL VIOLATION: Other peer violated probabilistic rule for to many active passive "
1832 "switches in differential sync: %u\n",
1833 op->differential_sync_iterations);
1925 ctx.hash = *element_hash;
1987 int s = (
salt * 7) % 64;
1991 x = (x >> s) | (x << (64 - s));
2004 int s = (
salt * 7) % 64;
2007 x = (x << s) | (x >> (64 - s));
2029 "[OP %p] inserting %lx (hash %s) into ibf\n",
2121 if (NULL !=
op->local_ibf)
2125 ((uint8_t)
op->ibf_number_buckets_per_element));
2126 if (NULL ==
op->local_ibf)
2129 "Failed to allocate local IBF\n");
2152 uint64_t buckets_sent = 0;
2154 op->differential_sync_iterations++;
2173 "sending ibf of size %u\n",
2181 "# sent IBF (order %u)",
2186 ibf =
op->local_ibf;
2190 unsigned int buckets_in_message;
2194 buckets_in_message =
ibf_size - buckets_sent;
2199 #if MEASURE_PERFORMANCE
2200 perf_store.ibf.sent += 1;
2201 perf_store.ibf.sent_var_bytes += (buckets_in_message *
IBF_BUCKET_SIZE);
2207 msg->offset = htonl (buckets_sent);
2208 msg->salt = htonl (
op->salt_send);
2213 buckets_in_message, &
msg[1],
msg->ibf_counter_bit_length);
2214 buckets_sent += buckets_in_message;
2216 "ibf chunk size %u, %llu/%u sent\n",
2217 (
unsigned int) buckets_in_message,
2218 (
unsigned long long) buckets_sent,
2239 float ibf_bucket_number_factor)
2243 return (((
int) (diff * ibf_bucket_number_factor)) | 1);
2250 decoded_elements,
unsigned int last_ibf_size)
2252 unsigned int next_size = (
unsigned int) ((last_ibf_size * 2)
2253 - (ibf_bucket_number_factor
2254 * decoded_elements));
2257 return next_size | 1;
2282 "Sending element %s\n",
2284 #if MEASURE_PERFORMANCE
2285 perf_store.element_full.received += 1;
2286 perf_store.element_full.received_var_bytes +=
el->size;
2313 "Dedicing to transmit the full set\n");
2329 op->set->content->elements_randomized,
2332 #if MEASURE_PERFORMANCE
2333 perf_store.full_done.sent += 1;
2383 #if MEASURE_PERFORMANCE
2384 perf_store.se.received += 1;
2385 perf_store.se.received_var_bytes += ntohs (
msg->header.
size) -
sizeof(
struct
2391 uint64_t other_size;
2395 op->set->content->elements);
2412 if ((
msg->se_count > 8) || (__builtin_popcount ((
int)
msg->se_count) != 1))
2415 "PROTOCOL VIOLATION: Invalid number of se transmitted by other peer %u\n",
2425 "# bytes of SE received",
2430 op->remote_element_count = other_size;
2432 if (
op->byzantine_upper_bound <
op->remote_element_count)
2435 "Exceeded configured upper bound <%lu> of element: %u\n",
2436 op->byzantine_upper_bound,
2437 op->remote_element_count);
2445 if (NULL == remote_se)
2473 if (diff_remote +
op->remote_element_count >
op->byzantine_upper_bound)
2474 diff_remote =
op->byzantine_upper_bound -
op->remote_element_count;
2475 if (diff_local +
op->local_element_count >
op->byzantine_upper_bound)
2476 diff_local =
op->byzantine_upper_bound -
op->local_element_count;
2477 if ((diff_remote < 0) || (diff_local < 0))
2481 "PROTOCOL VIOLATION: More element is set as upper boundary or other peer is "
2482 "malicious: remote diff %ld, local diff: %ld\n",
2483 diff_remote, diff_local);
2490 if (0 ==
op->remote_element_count)
2493 diff_local =
op->local_element_count;
2495 if (0 ==
op->local_element_count)
2498 diff_remote =
op->remote_element_count;
2501 diff = diff_remote + diff_local;
2502 op->remote_set_diff = diff_remote;
2505 uint64_t avg_element_size = 0;
2506 if (0 <
op->local_element_count)
2508 op->total_elements_size_local = 0;
2513 avg_element_size =
op->total_elements_size_local /
op->local_element_count;
2521 remote_element_count,
2525 rtt_bandwidth_tradeoff,
2527 ibf_bucket_number_factor);
2529 #if MEASURE_PERFORMANCE
2530 perf_store.se_diff_local = diff_local;
2531 perf_store.se_diff_remote = diff_remote;
2532 perf_store.se_diff = diff;
2533 perf_store.mode_of_operation =
op->mode_of_operation;
2540 "got se diff=%d, using ibf size %d\n",
2543 op->ibf_bucket_number_factor));
2548 set_debug =
getenv (
"GNUNET_SETU_BENCHMARK");
2549 if ((NULL != set_debug) &&
2550 (0 == strcmp (set_debug,
"1")))
2552 FILE *
f = fopen (
"set.log",
"a");
2553 fprintf (
f,
"%llu\n", (
unsigned long long) diff);
2559 (other_size < op->byzantine_lower_bound))
2570 "Deciding to go for full set transmission (diff=%d, own set=%llu)\n",
2572 (
unsigned long long)
op->initial_size);
2595 "Telling other peer that we expect its full set\n");
2597 #if MEASURE_PERFORMANCE
2598 perf_store.request_full.sent += 1;
2619 op->ibf_number_buckets_per_element,
2620 op->ibf_bucket_number_factor)))
2624 "Failed to send IBF, closing connection\n");
2654 op->active_passive_switch_required =
true;
2661 op->message_control_flow,
2667 "Skipping already sent processed element offer!\n");
2674 op->message_control_flow,
2681 "Double offer message sent found!\n");
2691 op->message_control_flow,
2698 "Double demand received found!\n");
2704 #if MEASURE_PERFORMANCE
2705 perf_store.offer.sent += 1;
2714 "[OP %p] sending element offer (%s) to peer\n",
2758 unsigned int num_decoded;
2765 op->remote_ibf->size))
2777 op->remote_ibf = NULL;
2780 "decoding IBF (size=%u)\n",
2799 "decoded ibf key %lx\n",
2800 (
unsigned long)
key.key_val);
2802 if ((num_decoded > diff_ibf->
size) ||
2803 ((num_decoded > 1) &&
2807 "detected cyclic ibf (decoded %u/%u)\n",
2825 if (next_size<ibf_min_size)
2826 next_size = ibf_min_size;
2832 "decoding failed, sending larger ibf (size %u)\n",
2838 #if MEASURE_PERFORMANCE
2839 perf_store.active_passive_switches += 1;
2842 op->salt_send =
op->salt_receive++;
2849 "Failed to send IBF, closing connection\n");
2858 "# of failed union operations (too large)",
2863 "set union failed: reached ibf limit\n");
2875 "transmitted all values, sending DONE\n");
2877 #if MEASURE_PERFORMANCE
2878 perf_store.done.sent += 1;
2896 else if (-1 == side)
2901 #if MEASURE_PERFORMANCE
2902 perf_store.inquery.sent += 1;
2903 perf_store.inquery.sent_var_bytes +=
sizeof(
struct IBF_Key);
2929 msg->salt = htonl (
op->salt_receive);
2934 "sending element inquiry for IBF key %lx\n",
2935 (
unsigned long)
key.key_val);
2988 op->remote_element_count = ntohl (
msg->remote_set_size);
2989 op->remote_set_diff = ntohl (
msg->remote_set_difference);
2990 op->local_set_diff = ntohl (
msg->local_set_difference);
2996 "PROTOCOL VIOLATION: Parameters transmitted from other peer do not satisfie byzantine "
3005 op->set->content->elements);
3006 uint64_t avg_element_size = 0;
3007 if (0 <
op->local_element_count)
3009 op->total_elements_size_local = 0;
3014 avg_element_size =
op->total_elements_size_local /
op->local_element_count;
3024 op->remote_set_diff,
3032 "PROTOCOL VIOLATION: Remote peer choose to send his full set first but correct mode would have been"
3057 unsigned int buckets_in_message;
3059 buckets_in_message = (ntohs (
msg->header.
size) -
sizeof *
msg)
3061 if (0 == buckets_in_message)
3066 if ((ntohs (
msg->header.
size) -
sizeof *
msg) != buckets_in_message
3074 if (ntohl (
msg->offset) !=
op->ibf_buckets_received)
3080 if (
msg->ibf_size !=
op->remote_ibf->size)
3085 if (ntohl (
msg->salt) !=
op->salt_receive)
3116 unsigned int buckets_in_message;
3129 op->differential_sync_iterations++;
3131 op->active_passive_switch_required =
false;
3133 #if MEASURE_PERFORMANCE
3134 perf_store.ibf.received += 1;
3135 perf_store.ibf.received_var_bytes += (ntohs (
msg->header.
size) -
sizeof *
msg);
3138 buckets_in_message = (ntohs (
msg->header.
size) -
sizeof *
msg)
3146 "Creating new ibf of size %u\n",
3147 ntohl (
msg->ibf_size));
3150 ((uint8_t)
op->ibf_number_buckets_per_element));
3151 op->salt_receive = ntohl (
msg->salt);
3153 "Receiving new IBF with salt %u\n",
3155 if (NULL ==
op->remote_ibf)
3158 "Failed to parse remote IBF, closing connection\n");
3162 op->ibf_buckets_received = 0;
3163 if (0 != ntohl (
msg->offset))
3174 "Received more of IBF\n");
3179 op->ibf_buckets_received,
3181 op->remote_ibf,
msg->ibf_counter_bit_length);
3182 op->ibf_buckets_received += buckets_in_message;
3184 if (
op->ibf_buckets_received ==
op->remote_ibf->size)
3187 "received full ibf\n");
3194 "Failed to decode IBF, closing connection\n");
3220 "sending element (size %u) to client\n",
3236 op->key_to_element));
3253 unsigned int num_demanded;
3256 op->demanded_hashes);
3258 op->message_control_flow,
3265 "In PHASE_FINISH_WAITING, pending %u demands -> %d\n",
3266 num_demanded,
op->peer_site);
3267 if (-1 != send_done)
3272 #if MEASURE_PERFORMANCE
3273 perf_store.done.sent += 1;
3285 "In PHASE_FINISH_CLOSING, pending %u demands %d\n",
3286 num_demanded,
op->peer_site);
3287 if (-1 != send_done)
3350 #if MEASURE_PERFORMANCE
3351 perf_store.element.received += 1;
3378 op->message_control_flow,
3385 "An element has been received more than once!\n");
3392 "Got element (size %u, hash %s) from peer\n",
3397 "# received elements",
3401 "# exchanged elements",
3405 op->received_total++;
3414 "# repeated elements",
3423 "Registering new element from remote peer\n");
3424 op->received_fresh++;
3432 if ((
op->received_total > 8) &&
3433 (
op->received_fresh <
op->received_total / 3))
3494 #if MEASURE_PERFORMANCE
3495 perf_store.element_full.received += 1;
3496 perf_store.element_full.received_var_bytes +=
element_size;
3508 "Got element (full diff, size %u, hash %s) from peer\n",
3513 "# received elements",
3517 "# exchanged elements",
3521 op->received_total++;
3527 "# repeated elements",
3537 "Registering new element from remote peer\n");
3538 op->received_fresh++;
3548 (
op->received_total >
op->remote_element_count) )
3552 "Other peer sent %llu elements while pretending to have %llu elements, failing operation\n",
3553 (
unsigned long long)
op->received_total,
3554 (
unsigned long long)
op->remote_element_count);
3575 unsigned int num_keys;
3585 != num_keys *
sizeof(
struct IBF_Key))
3605 const struct IBF_Key *ibf_key;
3606 unsigned int num_keys;
3620 #if MEASURE_PERFORMANCE
3621 perf_store.inquery.received += 1;
3622 perf_store.inquery.received_var_bytes += (ntohs (
msg->header.
size)
3627 "Received union inquiry\n");
3649 while (0 != num_keys--)
3686 #if MEASURE_PERFORMANCE
3687 perf_store.element_full.received += 1;
3734 op->remote_element_count = ntohl (
msg->remote_set_size);
3735 op->remote_set_diff = ntohl (
msg->remote_set_difference);
3736 op->local_set_diff = ntohl (
msg->local_set_difference);
3742 "PROTOCOL VIOLATION: Parameters transmitted from other peer do not satisfie byzantine "
3749 #if MEASURE_PERFORMANCE
3750 perf_store.request_full.received += 1;
3754 "Received request for full set transmission\n");
3758 op->set->content->elements);
3759 uint64_t avg_element_size = 0;
3760 if (0 <
op->local_element_count)
3762 op->total_elements_size_local = 0;
3767 avg_element_size =
op->total_elements_size_local /
op->local_element_count;
3776 op->remote_set_diff,
3784 "PROTOCOL VIOLATION: Remote peer choose to request the full set first but correct mode would have been"
3822 #if MEASURE_PERFORMANCE
3823 perf_store.full_done.received += 1;
3833 (
op->received_total !=
op->remote_element_count) )
3837 "Other peer sent only %llu/%llu fresh elements, failing operation\n",
3838 (
unsigned long long)
op->received_total,
3839 (
unsigned long long)
op->remote_element_count);
3846 "got FULL DONE, sending elements that other peer is missing\n");
3852 #if MEASURE_PERFORMANCE
3853 perf_store.full_done.sent += 1;
3866 "got FULL DONE, finishing\n");
3877 "Handle full done phase is %u\n",
3878 (
unsigned)
op->phase);
3900 unsigned int num_hashes;
3930 unsigned int num_hashes;
3945 #if MEASURE_PERFORMANCE
3946 perf_store.demand.received += 1;
3947 perf_store.demand.received_var_bytes += (ntohs (
mh->size) -
sizeof(
struct
3955 hash++, num_hashes--)
3970 op->message_control_flow,
3977 "Double demand message received found!\n");
3987 op->message_control_flow,
3994 "Double element message sent found!\n");
4006 #if MEASURE_PERFORMANCE
4007 perf_store.element.sent += 1;
4008 perf_store.element.sent_var_bytes += ee->
element.
size;
4019 "[OP %p] Sending demanded element (size %u, hash %s) to peer\n",
4025 "# exchanged elements",
4050 unsigned int num_hashes;
4084 unsigned int num_hashes;
4097 #if MEASURE_PERFORMANCE
4098 perf_store.offer.received += 1;
4099 perf_store.offer.received_var_bytes += (ntohs (
mh->size) -
sizeof(
struct
4107 hash++, num_hashes--)
4124 "Skipped sending duplicate demand\n");
4130 op->demanded_hashes,
4136 "[OP %p] Requesting element (hash %s)\n",
4139 #if MEASURE_PERFORMANCE
4140 perf_store.demand.sent += 1;
4146 op->message_control_flow,
4152 "Double demand message sent found!\n");
4161 op->message_control_flow,
4167 "Double offer message received found!\n");
4175 op->message_control_flow,
4181 "Element already expected!\n");
4222 if (
op->active_passive_switch_required)
4225 "PROTOCOL VIOLATION: Received done but role change is necessary\n");
4231 #if MEASURE_PERFORMANCE
4232 perf_store.done.received += 1;
4240 "got DONE (as passive partner), waiting for our demands to be satisfied\n");
4254 "got DONE (as active partner), waiting to finish\n");
4283 #if MEASURE_PERFORMANCE
4284 perf_store.over.received += 1;
4308 if (
op->suggest_id ==
id)
4376 "Client disconnected, cleaning up\n");
4377 if (NULL != (set =
cs->
set))
4382 "Destroying client's set\n");
4388 if (NULL != set->
se)
4410 if (NULL != (listener = cs->
listener))
4413 "Destroying client's listener\n");
4416 while (NULL != (
op = listener->
op_head))
4419 "Destroying incoming operation `%u' from peer `%s'\n",
4420 (
unsigned int)
op->client_request_id,
4460 if (0 !=
op->suggest_id)
4466 if (NULL == listener)
4472 if ((NULL != nested_context) &&
4511 if (NULL != nested_context)
4513 op->remote_element_count = ntohl (
msg->element_count);
4516 "Received P2P operation request (port %s) for active listener\n",
4524 op->timeout_task = NULL;
4530 "Suggesting incoming request with accept id %u to listener %p of client %p\n",
4559 "Client created new set for union operation\n");
4560 if (NULL !=
cs->
set)
4577 "Failed to allocate strata estimator\n");
4608 op->timeout_task = NULL;
4610 "Remote peer's incoming request timed out\n");
4640 "New incoming channel\n");
4796 "New listener created (port %s)\n",
4829 "Client rejected unknown operation %u\n",
4830 (
unsigned int) ntohl (
msg->accept_reject_id));
4835 "Peer request (app %s) rejected by client\n",
4874 if (NULL == (set = cs->
set))
4883 el.size = ntohs (
msg->header.
size) -
sizeof(*msg);
4885 el.element_type = ntohs (
msg->element_type);
4893 "Client inserts element %s of size %u\n",
4914 "Client inserted element %s of size %u twice (ignored)\n",
5035 if (NULL == (set = cs->
set))
5044 op->peer =
msg->target_peer;
5045 op->client_request_id = ntohl (
msg->request_id);
5046 op->byzantine =
msg->byzantine;
5047 op->byzantine_lower_bound = ntohl (
msg->byzantine_lower_bound);
5048 op->force_full =
msg->force_full;
5049 op->force_delta =
msg->force_delta;
5050 op->symmetric =
msg->symmetric;
5051 op->rtt_bandwidth_tradeoff =
msg->bandwidth_latency_tradeoff;
5052 op->ibf_bucket_number_factor =
msg->ibf_bucket_number_factor;
5053 op->ibf_number_buckets_per_element =
msg->ibf_number_of_buckets_per_element;
5054 op->byzantine_upper_bound =
msg->byzantine_upper_bond;
5055 op->active_passive_switch_required =
false;
5063 #if MEASURE_PERFORMANCE
5077 "Creating new CADET channel to port %s for set union\n",
5091 #if MEASURE_PERFORMANCE
5092 perf_store.operation_request.sent += 1;
5111 op->salt_receive = (
op->peer_site + 1) % 2;
5112 op->salt_send =
op->peer_site;
5116 "Initiating union operation evaluation\n");
5118 "# of total union operations",
5122 "# of initiated union operations",
5129 "sent op request with context message\n");
5132 "sent op request without context message\n");
5135 op->key_to_element);
5157 if (NULL == (
set = cs->
set))
5167 if (
op->client_request_id == ntohl (
msg->request_id))
5181 "Client canceled non-existent op %u\n",
5182 (uint32_t) ntohl (
msg->request_id));
5187 "Client requested cancel for op %u\n",
5188 (uint32_t) ntohl (
msg->request_id));
5214 if (NULL == (set =
cs->
set))
5228 "Client %p accepted request %u of listener %p that is no longer active\n",
5230 ntohl (
msg->accept_reject_id),
5241 "Client accepting request %u\n",
5242 (uint32_t) ntohl (
msg->accept_reject_id));
5243 listener =
op->listener;
5244 op->listener = NULL;
5252 op->client_request_id = ntohl (
msg->request_id);
5253 op->byzantine =
msg->byzantine;
5254 op->byzantine_lower_bound = ntohl (
msg->byzantine_lower_bound);
5255 op->force_full =
msg->force_full;
5256 op->force_delta =
msg->force_delta;
5257 op->symmetric =
msg->symmetric;
5258 op->rtt_bandwidth_tradeoff =
msg->bandwidth_latency_tradeoff;
5259 op->ibf_bucket_number_factor =
msg->ibf_bucket_number_factor;
5260 op->ibf_number_buckets_per_element =
msg->ibf_number_of_buckets_per_element;
5261 op->byzantine_upper_bound =
msg->byzantine_upper_bond;
5262 op->active_passive_switch_required =
false;
5268 #if MEASURE_PERFORMANCE
5280 "accepting set union operation\n");
5282 "# of accepted union operations",
5286 "# of total union operations",
5300 op->salt_receive = (
op->peer_site + 1) % 2;
5301 op->salt_send =
op->peer_site;
5304 op->key_to_element);
5310 if (
op->initial_size > 0)
5312 op->total_elements_size_local = 0;
5318 op->total_elements_size_local /
op->initial_size,
5327 #if MEASURE_PERFORMANCE
5328 perf_store.se.sent += 1;
5329 perf_store.se.sent_var_bytes +=
len;
5346 op->set->content->elements));
5381 "handled shutdown request\n");
5382 #if MEASURE_PERFORMANCE
5383 calculate_perf_store ();
5412 _ (
"Could not connect to CADET service\n"));
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
static struct GNUNET_ARM_Operation * op
Current operation.
static unsigned int phase
Processing stage that we are in.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
struct GNUNET_HashCode key
The key used in the DHT.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
static pa_context * context
Pulseaudio context.
uint16_t status
See PRISM_STATUS_*-constants.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * value
Value of the record to add/remove.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.
UnionOperationPhase
Current phase we are in for a union operation.
unsigned int strata_estimator_difference(const struct StrataEstimator *se1, const struct StrataEstimator *se2)
Estimate set difference with two strata estimators, i.e.
struct StrataEstimator * strata_estimator_create(unsigned int strata_count, uint32_t ibf_size, uint8_t ibf_hashnum)
Create a new strata estimator with the given parameters.
void strata_estimator_destroy(struct StrataEstimator *se)
Destroy a strata estimator, free all of its resources.
int strata_estimator_read(const void *buf, size_t buf_len, int is_compressed, struct StrataEstimator *se)
Read strata from the buffer into the given strata estimator.
size_t strata_estimator_write(const struct StrataEstimator *se, void *buf)
Write the given strata estimator to the buffer.
void strata_estimator_insert(struct StrataEstimator *se, struct IBF_Key key)
Add a key to the strata estimator.
struct StrataEstimator * strata_estimator_dup(struct StrataEstimator *se)
Make a copy of a strata estimator.
static void _GSS_operation_destroy(struct Operation *op)
Destroy the given operation.
#define IBF_MIN_SIZE
Minimal size of an ibf Based on the bsc thesis of Elias Summermatter (2021)
static void _GSS_operation_destroy2(struct Operation *op)
This function probably should not exist and be replaced by inlining more specific logic in the variou...
static void handle_client_create_set(void *cls, const struct GNUNET_SETU_CreateMessage *msg)
Called when a client wants to create a new set.
static int _GSS_is_element_of_operation(struct ElementEntry *ee, struct Operation *op)
Is element ee part of the set used by op?
static int check_client_set_add(void *cls, const struct GNUNET_SETU_ElementMessage *msg)
Called when a client wants to add or remove an element to a set it inhabits.
static struct KeyEntry * op_get_element(struct Operation *op, const struct GNUNET_HashCode *element_hash)
Determine whether the given element is already in the operation's element set.
static unsigned int get_next_ibf_size(float ibf_bucket_number_factor, unsigned int decoded_elements, unsigned int last_ibf_size)
#define MAX_IBF_SIZE
The maximum size of an ibf we use is MAX_IBF_SIZE=2^20.
#define MAX_BUCKETS_PER_MESSAGE
Number of buckets that can be transmitted in one message.
static uint32_t suggest_id
Counter for allocating unique IDs for clients, used to identify incoming operation requests from remo...
static void handle_union_p2p_request_full(void *cls, const struct TransmitFullMessage *msg)
static int check_union_p2p_request_full(void *cls, const struct TransmitFullMessage *mh)
Handle a request for full set transmission.
static int create_randomized_element_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Create randomized element hashmap for full sending.
static int decode_and_send(struct Operation *op)
Decode which elements are missing on each side, and send the appropriate offers and inquiries.
static int send_full_element_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Send a set element.
MESSAGE_CONTROL_FLOW_STATE
Different states to control the messages flow in differential mode.
@ MSG_CFS_EXPECTED
Track that receiving this message is expected.
@ MSG_CFS_SENT
Track that a message has been sent.
@ MSG_CFS_UNINITIALIZED
Initial message state.
@ MSG_CFS_RECEIVED
Track that message has been received.
static struct Listener * listener_head
Listeners are held in a doubly linked list.
static void send_full_set(struct Operation *op)
Switch to full set transmission for op.
#define PROBABILITY_FOR_NEW_ROUND
Is the estimated probability for a new round this values is based on the bsc thesis of Elias Summerma...
static int check_byzantine_bounds(struct Operation *op)
Check if all given byzantine parameters are in given boundaries.
static void handle_client_accept(void *cls, const struct GNUNET_SETU_AcceptMessage *msg)
Handle a request from the client to accept a set operation that came from a remote peer.
static void handle_union_p2p_over(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a over message from a remote peer.
static void handle_client_cancel(void *cls, const struct GNUNET_SETU_CancelMessage *msg)
Handle a request from the client to cancel a running set operation.
static void handle_union_p2p_inquiry(void *cls, const struct InquiryMessage *msg)
Send offers (for GNUNET_Hash-es) in response to inquiries (for IBF_Key-s).
static void handle_client_evaluate(void *cls, const struct GNUNET_SETU_EvaluateMessage *msg)
Called when a client wants to initiate a set operation with another peer.
static void handle_union_p2p_strata_estimator(void *cls, const struct StrataEstimatorMessage *msg)
Handle a strata estimator from a remote peer.
static int check_union_p2p_ibf(void *cls, const struct IBFMessage *msg)
Check an IBF message from a remote peer.
static struct IBF_Key get_ibf_key(const struct GNUNET_HashCode *src)
Derive the IBF key from a hash code and a salt.
static struct GNUNET_CADET_Handle * cadet
Handle to the cadet service, used to listen for and connect to remote peers.
static void maybe_finish(struct Operation *op)
Tests if the operation is finished, and if so notify.
static void handle_client_reject(void *cls, const struct GNUNET_SETU_RejectMessage *msg)
Called when the listening client rejects an operation request by another peer.
static int init_key_to_element_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator for initializing the key-to-element mapping of a union operation.
static int send_offers_iterator(void *cls, uint32_t key, void *value)
Iterator to send elements to a remote peer.
static void handle_union_p2p_demand(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a demand by the other peer for elements based on a list of struct GNUNET_HashCodes.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq)
Callback called when a client connects to the service.
static int check_union_p2p_inquiry(void *cls, const struct InquiryMessage *msg)
Send offers (for GNUNET_Hash-es) in response to inquiries (for IBF_Key-s).
static void * channel_new_cb(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
Method called whenever another peer has added us to a channel the other peer initiated.
static int check_union_p2p_strata_estimator(void *cls, const struct StrataEstimatorMessage *msg)
Handle a strata estimator from a remote peer.
static int send_missing_full_elements_iter(void *cls, uint32_t key, void *value)
Iterator over hash map entries, called to destroy the linked list of colliding ibf key entries.
static unsigned int get_size_from_difference(unsigned int diff, int number_buckets_per_element, float ibf_bucket_number_factor)
Compute the necessary order of an ibf from the size of the symmetric set difference.
static void handle_incoming_msg(void *cls, const struct OperationRequestMessage *msg)
Handle a request for a set operation from another peer.
static int in_shutdown
Are we in shutdown? if GNUNET_YES and the number of clients drops to zero, disconnect from CADET.
static int destroy_elements_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries to free element entries.
void send_offers_for_key(struct Operation *op, struct IBF_Key ibf_key)
Send offers (in the form of GNUNET_Hash-es) to the remote peer for the given IBF key.
static void shutdown_task(void *cls)
Called to clean up, after a shutdown has been requested.
static void handle_union_p2p_send_full(void *cls, const struct TransmitFullMessage *msg)
Handle send full message received from other peer.
static void handle_union_p2p_full_element(void *cls, const struct GNUNET_SETU_ElementMessage *emsg)
Handle an element message from a remote peer.
static struct GNUNET_STATISTICS_Handle * _GSS_statistics
Statistics handle.
static unsigned int num_clients
Number of active clients.
static void channel_window_cb(void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
Function called whenever an MQ-channel's transmission window size changes.
static void advance_generation(struct Set *set)
Advance the current generation of a set, adding exclusion ranges if necessary.
static int update_message_control_flow(struct GNUNET_CONTAINER_MultiHashMap *hash_map, enum MESSAGE_CONTROL_FLOW_STATE new_mcfs, const struct GNUNET_HashCode *hash_code, enum MESSAGE_TYPE mt)
Function to update, track and validate message received in differential sync.
static void check_max_differential_rounds(struct Operation *op)
Limit active passive switches in differential sync to configured security level.
static void handle_union_p2p_done(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a done message from a remote peer.
static int check_incoming_msg(void *cls, const struct OperationRequestMessage *msg)
Check a request for a set operation from another peer.
static void fail_union_operation(struct Operation *op)
Inform the client that the union operation has failed, and proceed to destroy the evaluate operation.
static int check_union_p2p_offer(void *cls, const struct GNUNET_MessageHeader *mh)
Check offer (of struct GNUNET_HashCodes).
static void send_client_done(void *cls)
Signal to the client that the operation has finished and destroy the operation.
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.
static void handle_union_p2p_full_done(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a "full done" message.
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.
static int prepare_ibf(struct Operation *op, uint32_t size)
Create an ibf with the operation's elements of the specified size.
static void op_register_element(struct Operation *op, struct ElementEntry *ee, int received)
Insert an element into the union operation's key-to-element mapping.
static void incoming_destroy(struct Operation *op)
Destroy an incoming request from a remote peer.
static struct Listener * listener_tail
Listeners are held in a doubly linked list.
static int determinate_avg_element_size_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator for determining average size.
static int check_union_p2p_full_element(void *cls, const struct GNUNET_SETU_ElementMessage *emsg)
Check a full element message from a remote peer.
MESSAGE_TYPE
Message types to track in message control flow.
@ DEMAND_MESSAGE
Demand message type.
@ OFFER_MESSAGE
Offer message type.
@ ELEMENT_MESSAGE
Element message type.
static enum GNUNET_GenericReturnValue check_valid_phase(const uint8_t allowed_phases[], size_t size_phases, struct Operation *op)
Validates the if a message is received in a correct phase.
GNUNET_SERVICE_MAIN("set", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(client_accept, GNUNET_MESSAGE_TYPE_SETU_ACCEPT, struct GNUNET_SETU_AcceptMessage, NULL), GNUNET_MQ_hd_var_size(client_set_add, GNUNET_MESSAGE_TYPE_SETU_ADD, struct GNUNET_SETU_ElementMessage, NULL), GNUNET_MQ_hd_fixed_size(client_create_set, GNUNET_MESSAGE_TYPE_SETU_CREATE, struct GNUNET_SETU_CreateMessage, NULL), GNUNET_MQ_hd_var_size(client_evaluate, GNUNET_MESSAGE_TYPE_SETU_EVALUATE, struct GNUNET_SETU_EvaluateMessage, NULL), GNUNET_MQ_hd_fixed_size(client_listen, GNUNET_MESSAGE_TYPE_SETU_LISTEN, struct GNUNET_SETU_ListenMessage, NULL), GNUNET_MQ_hd_fixed_size(client_reject, GNUNET_MESSAGE_TYPE_SETU_REJECT, struct GNUNET_SETU_RejectMessage, NULL), GNUNET_MQ_hd_fixed_size(client_cancel, GNUNET_MESSAGE_TYPE_SETU_CANCEL, struct GNUNET_SETU_CancelMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void handle_union_p2p_offer(void *cls, const struct GNUNET_MessageHeader *mh)
Handle offers (of struct GNUNET_HashCodes) and respond with demands (of struct GNUNET_HashCodes).
static void initialize_key_to_element(struct Operation *op)
Initialize the IBF key to element mapping local to this set operation.
static int check_union_p2p_demand(void *cls, const struct GNUNET_MessageHeader *mh)
Check a demand by the other peer for elements based on a list of struct GNUNET_HashCodes.
static enum GNUNET_GenericReturnValue free_values_iter(void *cls, const struct GNUNET_HashCode *key, void *value)
static struct Operation * get_incoming(uint32_t id)
Get the incoming socket associated with the given id.
static int destroy_key_to_element_iter(void *cls, uint32_t key, void *value)
Iterator over hash map entries, called to destroy the linked list of colliding ibf key entries.
static void handle_union_p2p_ibf(void *cls, const struct IBFMessage *msg)
Handle an IBF message from a remote peer.
static int check_union_p2p_send_full(void *cls, const struct TransmitFullMessage *msg)
Check send full message received from other peer.
static void handle_client_listen(void *cls, const struct GNUNET_SETU_ListenMessage *msg)
Called when a client wants to create a new listener.
#define SE_STRATA_COUNT
Number of IBFs in a strata estimator.
static void full_sync_plausibility_check(struct Operation *op)
Function that checks if full sync is plausible.
static void handle_union_p2p_elements(void *cls, const struct GNUNET_SETU_ElementMessage *emsg)
Handle an element message from a remote peer.
#define INCOMING_CHANNEL_TIMEOUT
How long do we hold on to an incoming channel if there is no local listener before giving up?
static void handle_client_set_add(void *cls, const struct GNUNET_SETU_ElementMessage *msg)
Called when a client wants to add or remove an element to a set it inhabits.
static int is_message_in_message_control_flow(struct GNUNET_CONTAINER_MultiHashMap *hash_map, struct GNUNET_HashCode *hash_code, enum MESSAGE_TYPE mt)
Validate if a message in differential sync si already received before.
#define SECURITY_LEVEL
Security level used for byzantine checks (2^80)
static int send_ibf(struct Operation *op, uint32_t ibf_size)
Send an ibf of appropriate size.
MODE_OF_OPERATION
Different modes of operations.
@ DIFFERENTIAL_SYNC
Mode just synchronizes the difference between sets.
@ FULL_SYNC_LOCAL_SENDING_FIRST
Mode send full set sending local set first.
@ FULL_SYNC_REMOTE_SENDING_FIRST
Mode request full set from remote peer.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
Clean up after a client has disconnected.
@ PHASE_FINISH_CLOSING
The protocol is almost finished, but we still have to flush our message queue and/or expect some elem...
@ PHASE_EXPECT_SE
We sent the request message, and expect a strata estimator.
@ PHASE_EXPECT_IBF_LAST
Continuation for multi part IBFs.
@ PHASE_FULL_RECEIVING
Phase that receives full set first and then sends elements that are the local peer missing.
@ PHASE_FINISH_WAITING
In the penultimate phase, we wait until all our demands are satisfied.
@ PHASE_FINISHED
In the ultimate phase, we wait until our demands are satisfied and then quit (sending another DONE me...
@ PHASE_PASSIVE_DECODING
The other peer is decoding the IBF we just sent.
@ PHASE_ACTIVE_DECODING
We are decoding an IBF.
@ PHASE_FULL_SENDING
After sending the full set, wait for responses with the elements that the local peer is missing.
@ PHASE_EXPECT_IBF
We sent the strata estimator, and expect an IBF.
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)
Function that chooses the optimal mode of operation depending on operation parameters.
static void channel_end_cb(void *channel_ctx, const struct GNUNET_CADET_Channel *channel)
Function called whenever a channel is destroyed.
static void send_client_element(struct Operation *op, const struct GNUNET_SETU_Element *element, enum GNUNET_SETU_Status status)
Send a result message to the client indicating that there is a new element.
static int determinate_done_message_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator for determining if all demands have been satisfied.
#define SE_IBF_HASH_NUM
The hash num parameter for the difference digests and strata estimators.
static void incoming_timeout_cb(void *cls)
Timeout happens iff:
#define SE_IBFS_TOTAL_SIZE
Primes for all 4 different strata estimators 61,67,71,73,79,83,89,97 348 Based on the bsc thesis of E...
#define DIFFERENTIAL_RTT_MEAN
AVG RTT for differential sync when k=2 and Factor = 2 Based on the bsc thesis of Elias Summermatter (...
static int op_get_element_iterator(void *cls, uint32_t key, void *value)
Iterator over the mapping from IBF keys to element entries.
static int prepare_ibf_iterator(void *cls, uint32_t key, void *value)
Insert a key into an ibf.
static int check_union_p2p_elements(void *cls, const struct GNUNET_SETU_ElementMessage *emsg)
Check an element message from a remote peer.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Function called by the service's run method to run service-specific setup code.
static int check_client_evaluate(void *cls, const struct GNUNET_SETU_EvaluateMessage *msg)
Called when a client wants to initiate a set operation with another peer.
uint8_t determine_strata_count(uint64_t avg_element_size, uint64_t element_count)
Calculates the optimal number of strata Estimators to send.
static unsigned int ibf_size
static unsigned int element_size
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Constants for network applications operating on top of the CADET service.
CADET service; establish channels to distant peers.
Constants for network protocols.
Two-peer set union operations.
API to create, modify and access statistics.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_float(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float *number)
Get a configuration value that should be a floating point number.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Generate a random unsigned 64-bit value.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_kdf(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
int GNUNET_CONTAINER_multihashmap32_get_multiple(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
#define GNUNET_log(kind,...)
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#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.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg_header_extra(mh, esize, type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header and extra space.
#define GNUNET_MQ_extract_nested_mh(var)
Return a pointer to the message at the end of the given message.
#define GNUNET_MESSAGE_TYPE_SETU_REQUEST
Notify the client of an incoming request from a remote peer.
#define GNUNET_MESSAGE_TYPE_SETU_REJECT
Reject a set request.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST
Request a set union operation from a remote peer.
#define GNUNET_MESSAGE_TYPE_SETU_RESULT
Handle result message from operation.
#define GNUNET_MESSAGE_TYPE_SETU_CREATE
Create a new local set.
#define GNUNET_MESSAGE_TYPE_SETU_ADD
Add element to set.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_DONE
Set operation is done.
#define GNUNET_MESSAGE_TYPE_SETU_ACCEPT
Accept an incoming set request.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_OVER
Request all missing elements from the other peer, based on their sets and the elements we previously ...
#define GNUNET_MESSAGE_TYPE_SETU_CANCEL
Cancel a set operation.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_OFFER
Tell the other peer which hashes match a given IBF key.
#define GNUNET_MESSAGE_TYPE_SETU_LISTEN
Listen for operation requests.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE
Request all missing elements from the other peer, based on their sets and the elements we previously ...
#define GNUNET_MESSAGE_TYPE_SETU_P2P_SEC
Compressed strata estimator.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_IBF
Invertible bloom filter.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS
Actual set elements.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_SEND_FULL
Signals other peer that all elements are sent.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT
Send a set element, not as response to a demand but because we're sending the full set.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_SE
Strata estimator.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_INQUIRY
Tell the other peer to send us a list of hashes that match an IBF key.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND
Demand the whole element from the other peer, given only the hash code.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL
Demand the whole element from the other peer, given only the hash code.
#define GNUNET_MESSAGE_TYPE_SETU_EVALUATE
Evaluate a set operation.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
#define GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE
Maximum size of a context message for set operation requests.
void GNUNET_SETU_element_hash(const struct GNUNET_SETU_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
GNUNET_SETU_Status
Status for the result callback.
@ GNUNET_SETU_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETU_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SETU_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETU_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
static unsigned int size
Size of the "table".
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.
struct InvertibleBloomFilter * ibf_create(uint32_t size, uint8_t hash_num)
Create an invertible bloom filter.
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.
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.
uint8_t ibf_get_max_counter(struct InvertibleBloomFilter *ibf)
Returns the minimal bytes needed to store the counter of the IBF.
State we keep per client.
struct GNUNET_MQ_Handle * mq
MQ to talk to client.
struct Listener * listener
Listener, if associated with the client, otherwise NULL.
struct Set * set
Set, if associated with the client, otherwise NULL.
struct GNUNET_SERVICE_Client * client
Client this is about.
Information about an element element in the set.
int remote
GNUNET_YES if the element is a remote element, and does not belong to the operation's set.
struct GNUNET_SET_Element element
The actual element.
unsigned int generation
First generation that includes this element.
struct GNUNET_HashCode element_hash
Hash of the element.
struct GNUNET_ARM_Operation * next
This is a doubly-linked list.
Opaque handle to a channel.
Opaque handle to the service.
Internal representation of the hash map.
Internal representation of the hash map.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Handle to a client that is connected to a service.
Message sent by a listening client to the service to accept performing the operation with the other p...
Sent to the service by the client in order to cancel a set operation.
Message sent by the client to the service to ask starting a new set to perform operations with.
Message sent by client to the service to add an element to the set.
uint16_t element_type
Type of the element to add or remove.
uint16_t reserved
For alignment, always zero.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_SETU_ADD.
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
Message sent by client to service to initiate a set operation as a client (not as listener).
Message sent by the client to the service to start listening for incoming requests to perform a certa...
Message sent by a listening client to the service to reject performing the operation with the other p...
A request for an operation with another client.
struct GNUNET_PeerIdentity peer_id
Identity of the requesting peer.
uint32_t accept_id
ID of the to identify the request when accepting or rejecting it.
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
uint64_t current_size
Current set size.
uint16_t result_status
Was the evaluation successful? Contains an enum GNUNET_SETU_Status in NBO.
uint16_t element_type
Type of the element attached to the message, if any.
uint32_t request_id
id the result belongs to
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
Context for op_get_element_iterator.
struct GNUNET_HashCode hash
FIXME.
struct KeyEntry * k
FIXME.
Message containing buckets of an invertible bloom filter.
Keys that can be inserted into and removed from an IBF.
estimate_best_mode_of_operation (uint64_t avg_element_size, uint64_t local_set_size,...
Invertible bloom filter (IBF).
int remote_decoded_count
If an IBF is decoded this count stores how many elements are on the remote site.