88#define RING_BUFFER_SIZE 16
93#define MAX_FC_RETRANSMIT_COUNT 1000
99#define MAX_CUMMULATIVE_ACKS 64
113#define FC_NO_CHANGE_REPLY_PROBABILITY 8
119#define IN_PACKET_SIZE_WITHOUT_MTU 128
125#define GOODPUT_AGING_SLOTS 4
131#define DEFAULT_WINDOW_SIZE (128 * 1024)
141#define MAX_INCOMING_REQUEST 16
147#define MAX_DV_DISCOVERY_SELECTION 16
157#define RECV_WINDOW_SIZE 4
166#define MIN_DV_PATH_LENGTH_FOR_INITIATOR 3
171#define MAX_DV_HOPS_ALLOWED 16
177#define MAX_DV_LEARN_PENDING 64
182#define MAX_DV_PATHS_TO_TARGET 3
189#define DELAY_WARN_THRESHOLD \
190 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
196#define DV_FORWARD_TIMEOUT \
197 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
202#define DEFAULT_ACK_WAIT_DURATION \
203 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
210#define DV_QUALITY_RTT_THRESHOLD \
211 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
217#define DV_PATH_VALIDITY_TIMEOUT \
218 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
224#define BACKCHANNEL_INACTIVITY_TIMEOUT \
225 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
231#define DV_PATH_DISCOVERY_FREQUENCY \
232 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
237#define EPHEMERAL_VALIDITY \
238 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
243#define REASSEMBLY_EXPIRATION \
244 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
250#define FAST_VALIDATION_CHALLENGE_FREQ \
251 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
256#define MAX_VALIDATION_CHALLENGE_FREQ \
257 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)
264#define ACK_CUMMULATOR_TIMEOUT \
265 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
271#define DV_LEARN_BASE_FREQUENCY GNUNET_TIME_UNIT_MINUTES
277#define DV_LEARN_QUALITY_THRESHOLD 100
282#define MAX_ADDRESS_VALID_UNTIL \
283 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)
288#define ADDRESS_VALIDATION_LIFETIME \
289 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
297#define MIN_DELAY_ADDRESS_VALIDATION GNUNET_TIME_UNIT_MILLISECONDS
305#define VALIDATION_RTT_BUFFER_FACTOR 3
313#define COMMUNICATOR_TOTAL_QUEUE_LIMIT 512
320#define QUEUE_LENGTH_LIMIT 32
325#define QUEUE_ENTRY_TIMEOUT \
326 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
333 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
2795 uint32_t last_window_consum_limit;
3121 "free_pending_acknowledgement\n");
3130 "remove pa from message\n");
3132 "remove pa from message %" PRIu64
"\n",
3135 "remove pa from message %u\n",
3138 "remove pa from message %s\n",
3169 while (NULL != (frag = root->
head_frag))
3174 while (NULL != (pa = frag->
pa_head))
3180 if (NULL != frag->
qe)
3183 frag->
qe->
pm = NULL;
3213 tc->details.core.pending_msg_head,
3214 tc->details.core.pending_msg_tail,
3217 if ((NULL != vl) && (NULL ==
pm->frag_parent))
3220 "Removing pm %" PRIu64
"\n",
3236 while (NULL != (pa =
pm->pa_head))
3240 "free pending pa null\n");
3241 if (NULL ==
pm->pa_tail)
3243 "free pending pa_tail null\n");
3246 "free pending pa prev null\n");
3249 "free pending pa next null\n");
3260 if (NULL !=
pm->bpm)
3263 if (NULL !=
pm->bpm->qe)
3274 "Freeing pm done\n");
3359 "free virtual link %p\n",
3411 if (NULL != vs->revalidation_task)
3414 vs->revalidation_task = NULL;
3420 "Remove key %s for address %s map size %u contains %u during freeing state\n",
3549 "Informing CORE clients about disconnect from %s\n",
3583 if (NULL != (vl =
dv->
vl))
3632 size_t addr_len = strlen (
address) + 1;
3637 md->
nt = htonl ((uint32_t)
nt);
3643 md->
cs = htonl ((uint32_t)
me->cs);
3646 memcpy (&md[1],
address, addr_len);
3670 if (
tc->details.monitor.one_shot)
3702 "Client %p of type %u connected\n",
3742 "Freeing neighbour\n");
3747 while (NULL != (dvh = neighbour->
dv_head))
3755 if (NULL != neighbour->
get)
3758 neighbour->
get = NULL;
3760 if (NULL != neighbour->
sc)
3765 neighbour->
sc = NULL;
3767 if (NULL != (
vl = neighbour->
vl))
3781 neighbour->
vl = NULL;
3816 "Informing CORE clients about connection to %s\n",
3847 if (s->tc->details.communicator.address_prefix !=
3848 queue->tc->details.communicator.address_prefix)
3851 "queue address %s qid %u compare with queue: address %s qid %u\n",
3856 if ((s->priority >
queue->priority) && (0 < s->q_capacity) &&
3884 queue->tc->details.communicator.
3888 if (
queue->tc->details.communicator.total_queue_length >=
3892 "Transmission on queue %s (QID %u) throttled due to communicator queue limit\n",
3897 "# Transmission throttled due to communicator queue limit",
3906 "Transmission on queue %s (QID %u) throttled due to communicator queue length limit\n",
3910 "# Transmission throttled due to queue queue limit",
3916 if (0 ==
queue->q_capacity)
3919 "Transmission on queue %s (QID %u) throttled due to communicator message has capacity %"
3925 "# Transmission throttled due to message queue capacity",
3932 if (NULL !=
queue->transmit_task)
3934 queue->transmit_task =
3938 "Considering transmission on queue `%s' QID %llu to %s\n",
3940 (
unsigned long long)
queue->qid,
3961 "Checking if link is down\n");
3969 pos->path_valid_until);
3984 if ((NULL == vl->
n) && (NULL == vl->
dv))
4015 "Cleaning up queue %u\n",
queue->qid);
4016 if (NULL !=
queue->mo)
4021 if (NULL !=
queue->transmit_task)
4024 queue->transmit_task = NULL;
4026 while (NULL != (pa =
queue->pa_head))
4037 tc->details.communicator.queue_head,
4038 tc->details.communicator.queue_tail,
4041 tc->details.communicator.total_queue_length);
4043 "Cleaning up queue with length %u\n",
4044 queue->queue_length);
4045 while (NULL != (
qe =
queue->queue_head))
4048 queue->queue_length--;
4049 tc->details.communicator.total_queue_length--;
4059 tc->details.communicator.total_queue_length))
4064 "# Transmission throttled due to communicator queue limit",
4067 for (
struct Queue *s =
tc->details.communicator.queue_head; NULL != s;
4077 if ((NULL != vl) && (neighbour == vl->
n))
4100 tc->details.communicator.addr_tail,
4102 if (NULL != ale->
sc)
4109 if (NULL != ale->
st)
4175 "Unknown Client %p disconnected, cleaning up.\n",
4182 "CORE Client %p disconnected, cleaning up.\n",
4186 while (NULL != (
pm =
tc->details.core.pending_msg_head))
4189 tc->details.core.pending_msg_head,
4190 tc->details.core.pending_msg_tail,
4199 "MONITOR Client %p disconnected, cleaning up.\n",
4209 "COMMUNICATOR Client %p disconnected, cleaning up.\n",
4212 if (NULL !=
tc->details.communicator.free_queue_entry_task)
4214 tc->details.communicator.free_queue_entry_task);
4215 while (NULL != (
q =
tc->details.communicator.queue_head))
4217 while (NULL != (ale =
tc->details.communicator.addr_head))
4225 "APPLICATION Client %p disconnected, cleaning up.\n",
4238 "Our last client disconnected\n");
4265 "Telling new CORE client about existing connection to %s\n",
4291 while (NULL != (cmc = vl->
cmc_tail))
4332 "New CORE client with PID %s registered\n",
4392 "client send response\n");
4401 "Confirming transmission of <%" PRIu64
"> to %s\n",
4423 unsigned int hops_array_length)
4425 uint64_t
choices[hops_array_length];
4427 unsigned int dv_count;
4445 if (dv_count <= hops_array_length)
4450 hops_array[dv_count++] = pos;
4453 for (
unsigned int i = 0; i < hops_array_length; i++)
4461 for (
unsigned int j = 0; j < i; j++)
4480 for (
unsigned int i = 0; i < hops_array_length; i++)
4482 hops_array[dv_count++] = pos;
4527 if (0 != ntohl (cmc->
im.
fc_on))
4534 "Acknowledge message with flow control id %" PRIu64
"\n",
4586 "# RECV_OK dropped: virtual link unknown",
4595 "CORE ack receiving message, increased CORE recv window to %d\n",
4601 while (NULL != (cmc = vl->
cmc_tail))
4628 "Receive-only communicator connected\n");
4631 tc->details.communicator.address_prefix =
4633 tc->details.communicator.cc = ntohl (cam->
cc);
4634 tc->details.communicator.can_burst = ntohl (cam->
can_burst);
4636 "Communicator for peer %s with prefix '%s' connected %s\n",
4638 tc->details.communicator.address_prefix,
4639 tc->details.communicator.can_burst ?
"can burst" :
4663 msize = ntohs (cb->
header.
size) -
sizeof(*cb);
4665 isize = ntohs (inbox->
size);
4671 is = (
const char *) inbox;
4675 if (
'\0' !=
is[msize - 1])
4720 "freeing timedout queue entries\n");
4722 tc->details.communicator.free_queue_entry_task = NULL;
4729 "checking QID %u for timedout queue entries\n",
4739 "diff to now %s \n",
4744 "Freeing timed out QueueEntry with MID %" PRIu64
4768 size_t payload_size)
4777 "Queueing %u bytes of payload for transmission <%" PRIu64
4778 "> on queue %llu to %s\n",
4779 (
unsigned int) payload_size,
4780 (NULL ==
pm) ? 0 :
pm->logging_uuid,
4781 (
unsigned long long)
queue->qid,
4789 memcpy (&smt[1],
payload, payload_size);
4798 "Create QueueEntry with MID %" PRIu64
4799 " and QID %u and prefix %s\n",
4802 queue->tc->details.communicator.address_prefix);
4813 "Retransmitting message <%" PRIu64
4814 "> remove pm from qe with MID: %llu \n",
4816 (
unsigned long long)
pm->qe->mid);
4822 if (0 ==
queue->q_capacity)
4829 " (pm type %u) was not send because queue has no capacity.\n",
4839 queue->queue_length++;
4840 queue->tc->details.communicator.total_queue_length++;
4842 queue->q_capacity--;
4844 "Queue %s with qid %u has capacity %" PRIu64
"\n",
4849 queue->tc->details.communicator.total_queue_length)
4853 if (0 ==
queue->q_capacity)
4860 if (NULL ==
tc->details.communicator.free_queue_entry_task)
4861 tc->details.communicator.free_queue_entry_task =
4867 if (NULL !=
pm && NULL != (pa =
pm->pa_head))
4869 while (
pm != pa->
pm)
4875 "Sending message MID %" PRIu64
4876 " of type %u (%u) and size %lu with MQ %p queue %s (QID %u) pending %"
4881 (
unsigned long) payload_size,
4885 (NULL ==
pm) ? 0 :
pm->logging_uuid);
4907 unsigned int candidates;
4919 for (
struct Queue *pos = n->queue_head; NULL != pos;
4920 pos = pos->next_neighbour)
4923 (pos->validated_until.abs_value_us > now.
abs_value_us))
4926 if (0 == candidates)
4931 "Could not route message of type %u to %s: no valid queue\n",
4935 "# route selection failed (all no valid queue)",
4948 for (
struct Queue *pos = n->queue_head; NULL != pos;
4949 pos = pos->next_neighbour)
4952 (pos->validated_until.abs_value_us > now.
abs_value_us))
4954 if ((sel1 == candidates) || (sel2 == candidates))
4957 "Routing message of type %u to %s using %s (#%u)\n",
4961 (sel1 == candidates) ? 1 : 2);
5021 sizeof(
key->material),
5023 "gnunet-transport-dv-key",
5024 strlen (
"gnunet-transport-dv-key")
5032 "Deriving backchannel key based on KM %s and IV %s\n",
5038 GCRY_CIPHER_MODE_CTR,
5041 &
key->material.aes_key,
5042 sizeof(
key->material.aes_key)));
5043 gcry_cipher_setctr (
key->cipher,
5044 &
key->material.aes_ctr,
5045 sizeof(
key->material.aes_ctr));
5081 gcry_cipher_encrypt (
key->cipher, dst, in_size, in, in_size));
5102 gcry_cipher_decrypt (
key->cipher,
5116 gcry_cipher_close (
key->cipher);
5152 unsigned int num_dvhs,
5162 uint16_t enc_body_size = ntohs (hdr->
size);
5189 sizeof(box_hdr.
iv));
5206 for (
unsigned int i = 0; i < num_dvhs; i++)
5209 unsigned int num_hops = dvh->
distance + 1;
5217 box_hdr.
orig_size = htons (
sizeof(buf));
5218 box_hdr.
num_hops = htons (num_hops);
5219 memcpy (buf, &box_hdr,
sizeof(box_hdr));
5230 for (
unsigned int j = 0; j < num_hops; j++)
5239 "Routing message of type %u to %s using DV (#%u/%u) via %s\n",
5248 memcpy (&dhops[num_hops],
enc,
sizeof(
enc));
5304 "Trying to route message of type %u to %s without fc\n",
5324 if ((NULL == n) && (NULL == dv))
5327 "Cannot route message of type %u to %s: no route\n",
5331 "# Messages dropped in routing: no acceptable method",
5337 "Routing message of type %u to %s with options %X\n",
5350 if ((NULL != n) && (NULL != dv))
5358 "Try to route message of type %u to %s without fc via neighbour\n",
5375 "Failed to route message, could not determine DV path\n");
5379 "encapsulate_for_dv 1\n");
5429 char *addr = (
char *) &tgna[1];
5432 "sending address %s length %u\n",
5468 size_t addresses_size =
5470 ->size_of_global_addresses;
5510 "Sending FC seq %u to %s with new window %llu %lu %u\n",
5532 "FC retransmission to %s failed, will retry in %s\n",
5582 "check_vl_transmission to target %s\n",
5591 "check_vl_transmission loop\n");
5598 "Stalled message %" PRIu64
5599 " transmission on VL %s due to flow control: %llu < %llu\n",
5603 (
unsigned long long) (
pm->bytes_msg
5609 "Target window on VL %s not stalled. Scheduling transmission on queue\n",
5622 "Direct neighbour %s not stalled\n",
5631 "Neighbour Queue QID: %u (%u) busy or invalid\n",
5644 struct Neighbour *nh_iter = pos->next_hop;
5647 if (pos->path_valid_until.abs_value_us <= now.
abs_value_us)
5657 "Stalled message %" PRIu64
5658 " transmission on next hop %s due to flow control: %llu < %llu\n",
5663 (
unsigned long long) (
pm->bytes_msg
5665 outbound_fc_window_size_used));
5675 "Next hop neighbour %s not stalled\n",
5684 "DV Queue QID: %u (%u) busy or invalid\n",
5692 "Eligible message %" PRIu64
" of size %u to %s: %llu/%llu\n",
5697 (
unsigned long long) (
pm->bytes_msg
5722 bytes_msg = ntohs (obmm->
size);
5728 "Don't have %s as a neighbour (anymore).\n",
5736 "# messages dropped (neighbour unknown)",
5744 "1 created pm %p storing vl %p\n",
5751 pm->bytes_msg = bytes_msg;
5752 memcpy (&
pm[1], obmm, bytes_msg);
5754 "Sending message of type %u with %u bytes as <%" PRIu64
5761 tc->details.core.pending_msg_head,
5762 tc->details.core.pending_msg_tail,
5792 uint16_t isize = ntohs (inbox->
size);
5793 const char *
is = ((
const char *) &cb[1]) + isize;
5794 size_t slen = strlen (
is) + 1;
5805 "Preparing backchannel transmission to %s:%s of type %u and size %u\n",
5808 ntohs (inbox->
type),
5809 ntohs (inbox->
size));
5814 memcpy (&be[1], inbox, isize);
5885 "Failed to store our own address `%s' in peerstore!\n",
5889 "Successfully stored our own address `%s' in peerstore!\n",
5918 if (NULL == ale->
sc)
5921 "Failed to store our address `%s' with peerstore\n",
5944 unsigned int add_success;
5946 dash = strchr (ale->
address,
'-');
5956 "Storing our address `%s' in peerstore until %s!\n",
5964 "Storing our address `%s' %s\n",
5966 GNUNET_NO == add_success ?
"not done" :
"failed");
5974 "Storing our address `%s'\n",
6008 char *address_without_port;
6012 ale->
address = (
const char *) &ale[1];
6016 memcpy (&ale[1],
address, slen);
6019 "Is this %s a local address (%s)\n",
6020 address_without_port,
6022 if (0 != strcmp (
"127.0.0.1", address_without_port))
6047 "Communicator added address `%s'!\n",
6048 (
const char *) &aam[1]);
6049 slen = ntohs (aam->
header.
size) -
sizeof(*aam);
6051 memcpy (
address, &aam[1], slen);
6059 tc->details.communicator.addr_tail,
6090 if (dam->
aid != ale->aid)
6094 "Communicator deleted address `%s'!\n",
6101 "Communicator removed address we did not even have.\n");
6150 unsigned int free_cmc)
6152 uint16_t
size = ntohs (
mh->size);
6158 "# CORE messages dropped (FC arithmetic overflow)",
6162 "CORE messages of type %u with %u bytes dropped (FC arithmetic overflow)\n",
6163 (
unsigned int) ntohs (
mh->type),
6164 (
unsigned int) ntohs (
mh->size));
6172 "# CORE messages dropped (FC window overflow)",
6176 "CORE messages of type %u with %u bytes dropped (FC window overflow)\n",
6177 (
unsigned int) ntohs (
mh->type),
6178 (
unsigned int) ntohs (
mh->size));
6204 memcpy (&im[1],
mh,
size);
6211 "Dropped message to CORE: no CORE client connected!\n");
6217 "Dropped message of type %u with %u bytes to CORE: no CORE client connected!\n",
6218 (
unsigned int) ntohs (
mh->type),
6219 (
unsigned int) ntohs (
mh->size));
6225 "Delivered message from %s of type %u to CORE recv window %d\n",
6259 uint16_t
size = ntohs (
mh->size);
6262 "Handling raw message of type %u with %u bytes\n",
6263 (
unsigned int) ntohs (
mh->type),
6264 (
unsigned int) ntohs (
mh->size));
6307 "Storing message for %s and type %u (%u) in ring buffer head %u is full %u\n",
6309 (
unsigned int) ntohs (
mh->type),
6310 (
unsigned int) ntohs (mh_copy->
type),
6322 "%u items stored in ring buffer\n",
6418 "Sending ACK with %u components to %s\n",
6428 for (
unsigned int i = 0; i < ac->
num_acks; i++)
6479 "Scheduling ACK %s for transmission to %s\n",
6585 "No virtual link for %s to handle fragment\n",
6609 fsize = ntohs (fb->
header.
size) -
sizeof(*fb);
6610 if (NULL == (rc = fc.
rc))
6613 + (msize + 7) / 8 *
sizeof(uint8_t) );
6629 target = (
char *) &rc[1];
6636 "Received fragment with size %u at offset %u/%u %u bytes missing from %s for NEW message %"
6647 target = (
char *) &rc[1];
6649 "Received fragment at offset %u/%u from %s for message %u\n",
6670 if (frag_off + fsize > msize)
6677 memcpy (&target[frag_off], &fb[1], fsize);
6679 for (
unsigned int i = frag_off; i < frag_off + fsize; i++)
6681 if (0 == (rc->
bitfield[i / 8] & (1 << (i % 8))))
6683 rc->
bitfield[i / 8] |= (1 << (i % 8));
6714 "Fragment reassembly complete for message %u\n",
6744 "check_send_msg with size %u: inner msg type %u and size %u (%lu %lu)\n",
6772 "Received reliability box from %s with UUID %s of type %u\n",
6775 (
unsigned int) ntohs (inbox->
type));
6833 uint16_t bytes_transmitted_ok)
6837 unsigned int age =
get_age ();
6859 uint16_t bytes_transmitted_ok)
6875 uint16_t bytes_transmitted_ok)
6894 "Complete transmission of message %" PRIu64
" %u\n",
6907 pos =
pm->frag_parent;
6911 "pos frag_off %lu pos bytes_msg %lu pmt %u parent %u\n",
6924 pos =
pm->frag_parent;