[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r13887 - gnunet/src/dv
From: |
gnunet |
Subject: |
[GNUnet-SVN] r13887 - gnunet/src/dv |
Date: |
Tue, 7 Dec 2010 16:09:29 +0100 |
Author: nevans
Date: 2010-12-07 16:09:29 +0100 (Tue, 07 Dec 2010)
New Revision: 13887
Modified:
gnunet/src/dv/gnunet-service-dv.c
gnunet/src/dv/test_transport_api_dv.c
gnunet/src/dv/test_transport_dv_data.conf
Log:
initial dv changes for atsi information handling, test case BROKEN
Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c 2010-12-07 15:04:44 UTC (rev 13886)
+++ gnunet/src/dv/gnunet-service-dv.c 2010-12-07 15:09:29 UTC (rev 13887)
@@ -27,9 +27,6 @@
* @author Christian Grothoff
* @author Nathan Evans
*
- * TODO: The gossip rates need to be worked out. Probably many other things
- * as well.
- *
*/
#include "platform.h"
#include "gnunet_client_lib.h"
@@ -1298,8 +1295,50 @@
}
#endif
+/**
+ * Get distance information from 'atsi'.
+ *
+ * @param atsi performance data
+ * @return connected transport distance
+ */
+static uint32_t
+get_atsi_distance (const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+ while ( (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) &&
+ (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) )
+ atsi++;
+ if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR)
+ {
+ GNUNET_break (0);
+ /* FIXME: we do not have distance data? Assume direct neighbor. */
+ return DIRECT_NEIGHBOR_COST;
+ }
+ return ntohl (atsi->value);
+}
/**
+ * Find latency information in 'atsi'.
+ *
+ * @param atsi performance data
+ * @return connection latency
+ */
+static struct GNUNET_TIME_Relative
+get_atsi_latency (const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+ while ( (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) &&
+ (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY) )
+ atsi++;
+ if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR)
+ {
+ GNUNET_break (0);
+ /* how can we not have latency data? */
+ return GNUNET_TIME_UNIT_SECONDS;
+ }
+ /* FIXME: Multiply by GNUNET_TIME_UNIT_MILLISECONDS (1) to get as a
GNUNET_TIME_Relative */
+ return GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, ntohl
(atsi->value));
+}
+
+/**
* Core handler for dv data messages. Whatever this message
* contains all we really have to do is rip it out of its
* DV layering and give it to our pal the DV plugin to report
@@ -1341,6 +1380,8 @@
int ret;
size_t packed_message_size;
char *cbuf;
+ uint32_t distance; /* Distance information */
+ struct GNUNET_TIME_Relative latency; /* Latency information */
packed_message_size = ntohs(incoming->header.size) -
sizeof(p2p_dv_MESSAGE_Data);
#if DEBUG_DV
@@ -1350,7 +1391,6 @@
if (ntohs (incoming->header.size) < sizeof (p2p_dv_MESSAGE_Data) + sizeof
(struct GNUNET_MessageHeader))
{
-
#if DEBUG_DV
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s': Message sizes don't add up, total size %u, expected at
least %u!\n", "dv service", ntohs(incoming->header.size), sizeof
(p2p_dv_MESSAGE_Data) + sizeof (struct GNUNET_MessageHeader));
@@ -1358,6 +1398,9 @@
return GNUNET_SYSERR;
}
+ /* Iterate over ATS_Information to get distance and latency */
+ latency = get_atsi_latency(atsi);
+ distance = get_atsi_distance(atsi);
dn = GNUNET_CONTAINER_multihashmap_get (direct_neighbors,
&peer->hashPubKey);
if (dn == NULL)
@@ -1481,9 +1524,6 @@
if (0 == memcmp (destination, peer, sizeof (struct GNUNET_PeerIdentity)))
{
/* FIXME: create stat: routing loop-discard! */
-#if DEBUG_DV_PEER_NUMBERS
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\n\n\nLoopy loo message\n\n\n");
-#endif
#if DEBUG_DV_MESSAGES
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1588,14 +1628,14 @@
struct PendingMessage *pending_message;
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
- {
+ {
#if DEBUG_DV_GOSSIP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s: Called with reason shutdown, shutting down!\n",
GNUNET_i2s(&my_identity));
#endif
- return;
- }
+ return;
+ }
if (send_context->fast_gossip_list_head != NULL)
{
@@ -2465,10 +2505,17 @@
#if DEBUG_DV_MESSAGES
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: learned about peer
%llu from which we have a previous unknown message, processing!\n",
my_short_id, referrer_peer_id);
#endif
- handle_dv_data_message(NULL,
&referrer->pending_messages[i].sender,
+ struct GNUNET_TRANSPORT_ATS_Information atsi[3];
+ atsi[0].type = htonl
(GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+ atsi[0].value = htonl
(referrer->pending_messages[i].distance);
+ atsi[1].type = htonl
(GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
+ atsi[1].value = htonl
((uint32_t)referrer->pending_messages[i].latency.rel_value);
+ atsi[2].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
+ atsi[2].value = htonl (0);
+ handle_dv_data_message(NULL,
+ &referrer->pending_messages[i].sender,
referrer->pending_messages[i].message,
- referrer->pending_messages[i].latency,
-
referrer->pending_messages[i].distance);
+ (const struct
GNUNET_TRANSPORT_ATS_Information *)&atsi);
GNUNET_free(referrer->pending_messages[i].message);
referrer->pending_messages[i].sender_id = 0;
}
@@ -2849,8 +2896,11 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s: Receives core connect message for peer %s distance %d!\n",
"dv", GNUNET_i2s(peer), distance);
#endif
+ uint32_t distance;
- if ((distance == DIRECT_NEIGHBOR_COST) &&
(GNUNET_CONTAINER_multihashmap_get(direct_neighbors, &peer->hashPubKey) ==
NULL))
+ distance = get_atsi_distance (atsi);
+ if ((distance == DIRECT_NEIGHBOR_COST) &&
+ (GNUNET_CONTAINER_multihashmap_get(direct_neighbors, &peer->hashPubKey)
== NULL))
{
peerinfo_iterator = GNUNET_malloc(sizeof(struct PeerIteratorContext));
neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor));
Modified: gnunet/src/dv/test_transport_api_dv.c
===================================================================
--- gnunet/src/dv/test_transport_api_dv.c 2010-12-07 15:04:44 UTC (rev
13886)
+++ gnunet/src/dv/test_transport_api_dv.c 2010-12-07 15:09:29 UTC (rev
13887)
@@ -25,7 +25,7 @@
#include "gnunet_testing_lib.h"
#include "gnunet_core_service.h"
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
#define TEST_ALL GNUNET_NO
@@ -385,18 +385,44 @@
static void
send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *
tc);
+/**
+ * Get distance information from 'atsi'.
+ *
+ * @param atsi performance data
+ * @return connected transport distance
+ */
+static uint32_t
+get_atsi_distance (const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+ while ( (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) &&
+ (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) )
+ atsi++;
+ if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR)
+ {
+ GNUNET_break (0);
+ /* FIXME: we do not have distance data? Assume direct neighbor. */
+ return 1;
+ }
+ return ntohl (atsi->value);
+}
+
static int
process_mtype (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- struct GNUNET_TIME_Relative latency,
- uint32_t distance)
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
{
struct TestMessageContext *pos = cls;
struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message;
+#if VERBOSE
+ uint32_t distance;
+#endif
if (pos->uid != ntohl(msg->uid))
return GNUNET_OK;
+#if VERBOSE
+ distance = get_atsi_distance(atsi);
+#endif
GNUNET_assert(0 == memcmp(peer, &pos->peer1->id, sizeof(struct
GNUNET_PeerIdentity)));
if (total_other_expected_messages == 0)
{
@@ -530,14 +556,12 @@
*/
pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
1,
- TIMEOUT,
pos,
&init_notify_peer2,
NULL,
NULL,
NULL, NULL,
GNUNET_YES, NULL, GNUNET_YES,
handlers);
-
}
@@ -569,7 +593,6 @@
*/
pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg,
1,
- TIMEOUT,
pos,
&init_notify_peer1,
NULL, NULL,
@@ -801,8 +824,7 @@
static void all_connect_handler (void *cls,
const struct
GNUNET_PeerIdentity * peer,
- struct GNUNET_TIME_Relative latency,
- uint32_t distance)
+ const struct GNUNET_TRANSPORT_ATS_Information
*atsi)
{
struct GNUNET_TESTING_Daemon *d = cls;
struct GNUNET_TESTING_Daemon *second_daemon;
@@ -810,6 +832,9 @@
#if !TEST_ALL
struct TestMessageContext *temp_context;
#endif
+ uint32_t distance;
+ distance = get_atsi_distance(atsi);
+
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance
%u\n",
d->shortname,
@@ -884,7 +909,6 @@
new_peer = GNUNET_malloc(sizeof(struct PeerContext));
new_peer->peer_handle = GNUNET_CORE_connect(cfg,
1,
- GNUNET_TIME_UNIT_FOREVER_REL,
d, NULL,
&all_connect_handler,
NULL, NULL, NULL,
Modified: gnunet/src/dv/test_transport_dv_data.conf
===================================================================
--- gnunet/src/dv/test_transport_dv_data.conf 2010-12-07 15:04:44 UTC (rev
13886)
+++ gnunet/src/dv/test_transport_dv_data.conf 2010-12-07 15:09:29 UTC (rev
13887)
@@ -20,6 +20,9 @@
PORT = 2567
[transport-tcp]
+ENABLE_NAT_CLIENT = NO
+ENABLE_NAT_SERVER = NO
+ENABLE_UPNP = NO
PORT = 2568
[transport-udp]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r13887 - gnunet/src/dv,
gnunet <=