#include "gnunet_nse_service.h"
#include "nse.h"
+/**
+ * Send messages on connect.
+ */
+#define SEND_ON_CONNECT GNUNET_YES
+
/**
* Should we generate a histogram with the time stamps of when we received
* NSE messages to disk? (for performance evaluation only, not useful in
mean = 0.0;
sum = 0.0;
sumweight = 0.0;
- for (i=0;i<estimate_count; i++)
+ for (i = 0; i < estimate_count; i++)
{
- val = htonl (size_estimate_messages[(estimate_index - i + HISTORY_SIZE) % HISTORY_SIZE].matching_bits);
- weight = estimate_count + 1 - i;
+ val = htonl (size_estimate_messages[(estimate_index - i + HISTORY_SIZE)
+ % HISTORY_SIZE].matching_bits);
+ weight = 1; /* was: estimate_count + 1 - i; */
temp = weight + sumweight;
q = val - mean;
em->header.type
= htons (GNUNET_MESSAGE_TYPE_NSE_ESTIMATE);
em->reserved = htonl (0);
+ em->timestamp = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get());
em->size_estimate = mean - 1.0/3.0;
em->std_deviation = std_dev;
GNUNET_STATISTICS_set (stats,
setup_flood_message (estimate_index, current_timestamp);
next_message.matching_bits = htonl (0); /* reset for 'next' round */
hop_count_max = 0;
- for (i=0;i<HISTORY_SIZE;i++)
+ for (i = 0; i < HISTORY_SIZE; i++)
hop_count_max = GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count),
hop_count_max);
GNUNET_CONTAINER_multihashmap_iterate (peers,
{
/* still stuck in previous round, no point to update, check that
we are active here though... */
+#if SEND_ON_CONNECT
GNUNET_break (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK);
+#endif
return GNUNET_OK;
}
if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_break (0);
return GNUNET_OK;
}
+
ts = GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp);
+
if (ts.abs_value == current_timestamp.abs_value)
idx = estimate_index;
else if (ts.abs_value == current_timestamp.abs_value - gnunet_nse_interval.rel_value)
}
if (matching_bits <= ntohl (size_estimate_messages[idx].matching_bits))
{
+ if ( (idx < estimate_index) &&
+ (peer_entry->previous_round == GNUNET_YES) )
+ peer_entry->previous_round = GNUNET_NO;
+ /* push back our result now, that peer is spreading bad information... */
+ if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
+ peer_entry->transmit_task = GNUNET_SCHEDULER_add_now (&transmit_task,
+ peer_entry);
/* Not closer than our most recent message, no need to do work here */
GNUNET_STATISTICS_update (stats,
"# flood messages ignored (had closer already)",
&peer->hashPubKey,
peer_entry,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+#if SEND_ON_CONNECT
peer_entry->transmit_task = GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1),
&transmit_task,
peer_entry);
+#endif
}
current_timestamp.abs_value = (now.abs_value / gnunet_nse_interval.rel_value) * gnunet_nse_interval.rel_value;
next_timestamp.abs_value = current_timestamp.abs_value + gnunet_nse_interval.rel_value;
- for (i=0;i<HISTORY_SIZE;i++)
+ for (i = 0; i < HISTORY_SIZE; i++)
{
prev_time.abs_value = current_timestamp.abs_value - (HISTORY_SIZE - i - 1) * gnunet_nse_interval.rel_value;
setup_flood_message (i, prev_time);