* Timeout for this message
*/
struct GNUNET_TIME_Relative timeout;
+
+#if DEBUG_DV_MESSAGES
+ /**
+ * Unique ID for DV message
+ */
+ unsigned int uid;
+#endif
};
/**
toSend->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DATA);
toSend->sender = htonl (sender_id);
toSend->recipient = htonl (recipient_id);
+#if DEBUG_DV_MESSAGES
+ toSend->uid = send_context->uid; /* Still sent around in network byte order */
+#endif
+
memcpy (&toSend[1], send_context->message, send_context->message_size);
#if DEBUG_DV
- memcpy(&shortname, GNUNET_i2s(&specific_neighbor->identity), 4);
+ memcpy(&shortname, GNUNET_i2s(send_context->distant_peer), 4);
shortname[4] = '\0';
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send to destination `%s' via `%s' size %u\n", "DV", &shortname, GNUNET_i2s(&specific_neighbor->referrer->identity), msg_size);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send to destination `%s' via `%s' size %u\n", "DV", &shortname, GNUNET_i2s(recipient), msg_size);
#endif
GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
if (core_transmit_handle == NULL)
core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, send_context->importance, send_context->timeout, recipient, msg_size, &core_transmit_notify, NULL);
else
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s': Failed to schedule pending transmission (must be one in progress!)\n", "dv service");
-
+ {
+#if DEBUG_DV
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s': Failed to schedule pending transmission (must be one in progress!)\n", "dv service");
+#endif
+ }
return GNUNET_YES;
}
* @param message the packed message
* @param message_size size of the message
* @param importance what priority to send this message with
+#if DEBUG_DV_MESSAGES
+ * @param uid unique id for this message
+#endif
* @param timeout how long to possibly delay sending this message
*/
static int
const struct DistantNeighbor * specific_neighbor,
const struct GNUNET_MessageHeader * message,
size_t message_size,
- unsigned int importance, struct GNUNET_TIME_Relative timeout)
+ unsigned int importance,
+#if DEBUG_DV_MESSAGES
+ unsigned int uid,
+#endif
+ struct GNUNET_TIME_Relative timeout)
{
p2p_dv_MESSAGE_Data *toSend;
unsigned int msg_size;
toSend->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DATA);
toSend->sender = htonl (sender_id);
toSend->recipient = htonl (recipient_id);
+#if DEBUG_DV_MESSAGES
+ toSend->uid = htonl(uid);
+#endif
#if DEBUG_DV_PEER_NUMBERS
GNUNET_CRYPTO_hash_to_enc (&target->identity.hashPubKey, &encPeerTo);
encPeerTo.encoding[4] = '\0';
struct CheckPeerContext checkPeerCtx;
#endif
char *sender_id;
-
char *direct_id;
-
int ret;
size_t packed_message_size;
char *cbuf;
{
packed_message = (struct GNUNET_MessageHeader *)&cbuf[offset];
-#if DEBUG_DV
+#if DEBUG_DV_MESSAGES
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s: Receives %s message for me, size %d type %d, cost %u!\n", "dv", "DV DATA", ntohs(packed_message->size), ntohs(packed_message->type), pos->cost);
+ "%s: Receives %s message for me, uid %u, size %d type %d, cost %u from %s!\n", my_short_id, "DV DATA", ntohl(incoming->uid), ntohs(packed_message->size), ntohs(packed_message->type), pos->cost, GNUNET_i2s(&pos->identity));
#endif
GNUNET_break_op (ntohs (packed_message->type) != GNUNET_MESSAGE_TYPE_DV_GOSSIP);
GNUNET_break_op (ntohs (packed_message->type) != GNUNET_MESSAGE_TYPE_DV_DATA);
if (fdc.dest == NULL)
{
-#if DEBUG_DV
+#if DEBUG_DV_MESSAGES
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s: Receives %s message for someone else that we don't know (id %u)!\n", "dv", "DV DATA", tid);
+ "%s: Receives %s message uid %u for someone we don't know (id %u)!\n", my_short_id, "DV DATA", ntohl(incoming->uid), tid);
#endif
return GNUNET_OK;
}
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\n\n\nLoopy loo message\n\n\n");
#endif
-#if DEBUG_MESSAGE_DROP
+#if DEBUG_DV_MESSAGES
direct_id = GNUNET_strdup(GNUNET_i2s(&dn->identity));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s: DROPPING MESSAGE type %d, routing loop! Message immediately from %s!\n", GNUNET_i2s(&my_identity), ntohs(((struct GNUNET_MessageHeader *)&incoming[1])->type), direct_id);
+ "%s: DROPPING MESSAGE uid %u type %d, routing loop! Message immediately from %s!\n", my_short_id, ntohl(incoming->uid), ntohs(packed_message->type), direct_id);
#endif
return GNUNET_OK;
}
&original_sender,
packed_message, DV_PRIORITY, DV_DELAY);*/
-#if DEBUG_DV
+#if DEBUG_DV_MESSAGES
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s: Sends message size %d on!\n", "dv", packed_message_size);
+ "%s: FORWARD %s message for %s, uid %u, size %d type %d, cost %u!\n", my_short_id, "DV DATA", GNUNET_i2s(&destination), ntohl(incoming->uid), ntohs(packed_message->size), ntohs(packed_message->type), pos->cost);
+#endif
+
+ ret = send_message(&destination,
+ &original_sender,
+ NULL,
+ packed_message,
+ packed_message_size,
+ default_dv_priority,
+#if DEBUG_DV_MESSAGES
+ ntohl(incoming->uid),
#endif
- ret = send_message(&destination, &original_sender, NULL, packed_message, packed_message_size, default_dv_priority, GNUNET_TIME_relative_get_forever());
+ GNUNET_TIME_relative_get_forever());
if (ret != GNUNET_SYSERR)
return GNUNET_OK;
struct GNUNET_PeerIdentity *direct;
struct GNUNET_MessageHeader *message_buf;
char *temp_pos;
-
int offset;
static struct GNUNET_CRYPTO_HashAsciiEncoded dest_hash;
struct DV_SendContext *send_context;
+#if DEBUG_DV_MESSAGES
+ char *cbuf;
+ struct GNUNET_MessageHeader *packed_message;
+#endif
if (client_handle == NULL)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: asked to send message to `%s', but address is for `%s'!", "DV SERVICE", GNUNET_i2s(&send_msg->target), (const char *)&dest_hash.encoding);
}
-
- GNUNET_CRYPTO_hash_to_enc (&destination->hashPubKey, &dest_hash); /* GNUNET_i2s won't properly work, need to hash one ourselves */
- dest_hash.encoding[4] = '\0';
#if DEBUG_DV_MESSAGES
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s DV SEND called with message of size %d type %d, destination `%s' via `%s'\n", my_short_id, message_size, ntohs(message_buf->type), (const char *)&dest_hash.encoding, GNUNET_i2s(direct));
+ cbuf = (char *)message_buf;
+ offset = 0;
+ while(offset < message_size)
+ {
+ packed_message = (struct GNUNET_MessageHeader *)&cbuf[offset];
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: DV PLUGIN SEND uid %u type %d to %s\n", my_short_id, ntohl(send_msg->uid), ntohs(packed_message->type), GNUNET_i2s(destination));
+ offset += ntohs(packed_message->size);
+ }
+ /*GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: DV PLUGIN SEND uid %u type %d to %s\n", my_short_id, ntohl(send_msg->uid), ntohs(message_buf->type), GNUNET_i2s(destination));*/
#endif
+ GNUNET_CRYPTO_hash_to_enc (&destination->hashPubKey, &dest_hash); /* GNUNET_i2s won't properly work, need to hash one ourselves */
+ dest_hash.encoding[4] = '\0';
send_context = GNUNET_malloc(sizeof(struct DV_SendContext));
send_result_msg = GNUNET_malloc(sizeof(struct GNUNET_DV_SendResultMessage));
send_context->message = message_buf;
send_context->message_size = message_size;
send_context->send_result = send_result_msg;
+#if DEBUG_DV_MESSAGES
+ send_context->uid = send_msg->uid;
+#endif
if (send_message_via(&my_identity, direct, send_context) != GNUNET_YES)
{
return GNUNET_YES;
}
+
/**
* Task run during shutdown.
*
size_t offset;
size_t size;
size_t ret;
+ char *addr1;
+ char *addr2;
if (hello_context->addresses_to_add == 0)
return 0;
offset += sizeof(struct GNUNET_PeerIdentity);
/* Copy the direct peer identity to buffer */
memcpy(&addr_buffer[offset], hello_context->direct_peer, sizeof(struct GNUNET_PeerIdentity));
+ addr1 = GNUNET_strdup(GNUNET_i2s(hello_context->direct_peer));
+ addr2 = GNUNET_strdup(GNUNET_i2s(&hello_context->distant_peer));
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: GIVING HELLO %s%s%s to TRANSPORT\n", my_short_id,my_short_id, addr1, addr2);
+ GNUNET_free(addr1);
+ GNUNET_free(addr2);
ret = GNUNET_HELLO_add_address ("dv",
GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_UNIT_HOURS), addr_buffer, size,
return GNUNET_YES;
}
+#if INSANE_GOSSIP
+/**
+ * Iterator over hash map entries.
+ *
+ * @param cls closure
+ * @param key current key code
+ * @param value value in the hash map
+ * @return GNUNET_YES if we should continue to
+ * iterate,
+ * GNUNET_NO if not.
+ */
+static int gossip_all_to_all_iterator (void *cls,
+ const GNUNET_HashCode * key,
+ void *value)
+{
+ struct DirectNeighbor *direct = value;
+
+ GNUNET_CONTAINER_multihashmap_iterate (ctx.extended_neighbors, &add_all_extended_peers, direct->send_context);
+
+ if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel(sched, direct->send_context->task);
+
+ direct->send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, direct->send_context);
+ return GNUNET_YES;
+}
+
+/**
+ * Task run during shutdown.
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+gossip_all_to_all (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_CONTAINER_multihashmap_iterate (ctx.direct_neighbors, &gossip_all_to_all_iterator, NULL);
+
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
+ &gossip_all_to_all,
+ NULL);
+
+}
+#endif
/**
* Iterate over all current direct peers, add newly connected peer
* to the fast gossip list for that peer so we get DV routing
GNUNET_TIME_UNIT_FOREVER_REL,
&shutdown_task,
NULL);
+#if INSANE_GOSSIP
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
+ &gossip_all_to_all,
+ NULL);
+#endif
}
if (pos->uid != ntohl(msg->uid))
return GNUNET_OK;
+ GNUNET_assert(0 == memcmp(peer, &pos->peer1->id, sizeof(struct GNUNET_PeerIdentity)));
if (total_other_expected_messages == 0)
{
total_messages_received++;
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received message from `%4s', type %d, distance %u.\n", GNUNET_i2s (peer), ntohs(message->type), distance);
+ "Received message from `%4s', type %d, uid %u, distance %u.\n", GNUNET_i2s (peer), ntohs(message->type), ntohl(msg->uid), distance);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Total messages received %d, expected %d.\n", total_messages_received, expected_messages);
#endif
total_other_messages++;
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received message from `%4s', type %d, distance %u.\n", GNUNET_i2s (peer), ntohs(message->type), distance);
+ "Received message from `%4s', type %d, uid %u, distance %u.\n", GNUNET_i2s (peer), ntohs(message->type), ntohl(msg->uid), distance);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Total messages received %d, expected %d.\n", total_other_messages, total_other_expected_messages);
#endif
if ((total_messages_received == expected_messages) && (total_other_messages == 0))
{
GNUNET_SCHEDULER_cancel (sched, die_task);
- GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 40), &send_other_messages, NULL);
+ GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45), &send_other_messages, NULL);
}
else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages))
{
temp_context->peer1 = d;
temp_context->peer2 = second_daemon;
temp_context->next = other_test_messages;
- temp_context->uid = total_connections;
+ temp_context->uid = total_connections + temp_total_other_messages;
temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
other_test_messages = temp_context;
}
fprintf(dotOutFile, "\tn%s -- n%s [color=red];\n", d->shortname, second_shortname);
else if (distance == 4)
fprintf(dotOutFile, "\tn%s -- n%s [color=green];\n", d->shortname, second_shortname);
+ else
+ fprintf(dotOutFile, "\tn%s -- n%s [color=brown];\n", d->shortname, second_shortname);
}
GNUNET_free(second_shortname);
}