/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ (C) 2009-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
*/
#define TYPEMAP_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
+/**
+ * How often do we transmit our typemap on first attempt?
+ */
+#define TYPEMAP_FREQUENCY_FIRST GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+
/**
* Message ready for encryption. This struct is followed by the
*/
struct GSC_TypeMap *tmap;
- /**
- * At what time did we initially establish this session?
- * (currently unused, should be integrated with ATS in the
- * future...).
- */
- struct GNUNET_TIME_Absolute time_established;
-
/**
* Task to transmit corked messages with a delay.
*/
*/
int ready_to_transmit;
+ /**
+ * Is this the first time we're sending the typemap? If so,
+ * we want to send it a bit faster the second time. 0 if
+ * we are sending for the first time, 1 if not.
+ */
+ int first_typemap;
};
struct GNUNET_MessageHeader *hdr;
struct GNUNET_TIME_Relative delay;
- delay = TYPEMAP_FREQUENCY;
+ if (0 == session->first_typemap)
+ {
+ delay = TYPEMAP_FREQUENCY_FIRST;
+ session->first_typemap = 1;
+ }
+ else
+ {
+ delay = TYPEMAP_FREQUENCY;
+ }
/* randomize a bit to avoid spont. sync */
- delay.rel_value +=
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
+ delay.rel_value_us +=
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000 * 1000);
session->typemap_task =
GNUNET_SCHEDULER_add_delayed (delay, &transmit_typemap_task, session);
GNUNET_STATISTICS_update (GSC_stats,
session->tmap = GSC_TYPEMAP_create ();
session->peer = *peer;
session->kxinfo = kx;
- session->time_established = GNUNET_TIME_absolute_get ();
session->typemap_task =
GNUNET_SCHEDULER_add_now (&transmit_typemap_task, session);
GNUNET_assert (GNUNET_OK ==
{
pos = nxt;
nxt = pos->next;
- if ((pos->deadline.abs_value < now.abs_value) &&
+ if ((pos->deadline.abs_value_us < now.abs_value_us) &&
(GNUNET_YES != pos->was_solicited))
{
GNUNET_STATISTICS_update (GSC_stats,
now = GNUNET_TIME_absolute_get ();
if ((msize == 0) ||
((msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) &&
- (min_deadline.abs_value > now.abs_value)))
+ (min_deadline.abs_value_us > now.abs_value_us)))
{
/* not enough ready yet, try to solicit more */
solicit_messages (session);
/* FIXME: code duplication with clients... */
cnm.header.size = htons (sizeof (struct ConnectNotifyMessage));
cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
- // FIXME: full ats...
- cnm.ats_count = htonl (0);
cnm.peer = session->peer;
GNUNET_SERVER_transmit_context_append_message (tc, &cnm.header);
return GNUNET_OK;