[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8611 - in GNUnet/src/applications/dv_dht: module tools
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8611 - in GNUnet/src/applications/dv_dht: module tools |
Date: |
Tue, 30 Jun 2009 16:32:35 -0600 |
Author: nevans
Date: 2009-06-30 16:32:35 -0600 (Tue, 30 Jun 2009)
New Revision: 8611
Modified:
GNUnet/src/applications/dv_dht/module/routing.c
GNUnet/src/applications/dv_dht/module/table.c
GNUnet/src/applications/dv_dht/module/table.h
GNUnet/src/applications/dv_dht/tools/dv_test.conf
GNUnet/src/applications/dv_dht/tools/gnunetd_dv.conf
Log:
Modified: GNUnet/src/applications/dv_dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/routing.c 2009-06-30 22:32:18 UTC
(rev 8610)
+++ GNUnet/src/applications/dv_dht/module/routing.c 2009-06-30 22:32:35 UTC
(rev 8611)
@@ -410,6 +410,7 @@
#endif
break;
}
+
routed++;
GNUNET_array_grow (q->results, q->result_count, q->result_count + 1);
q->results[q->result_count - 1] = hc;
@@ -802,6 +803,11 @@
j++;
}
GNUNET_free (aput);
+
+ store = 0;
+ if (GNUNET_YES == GNUNET_DV_DHT_am_closest_peer(&put->key))
+ store = 1;
+
if (store != 0)
{
now = GNUNET_get_time ();
@@ -851,7 +857,6 @@
const DV_DHT_MESSAGE *result;
#if DEBUG_ROUTING
GNUNET_EncName enc;
- unsigned long long queryuid;
#endif
if (ntohs (msg->size) < sizeof (DV_DHT_MESSAGE))
Modified: GNUnet/src/applications/dv_dht/module/table.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.c 2009-06-30 22:32:18 UTC
(rev 8610)
+++ GNUnet/src/applications/dv_dht/module/table.c 2009-06-30 22:32:35 UTC
(rev 8611)
@@ -385,8 +385,17 @@
double d;
bucket = get_bit_distance (target, have);
- d = bucket * 32;
+ /*d = bucket * 32;
d = exp2 (d / (sizeof (GNUNET_HashCode) * 8));
+ I can't understand this code. Why multiply bucket by 32?
+ I say if we want a scaled value, assume we have a bucket
+ for each bit. Obviously we can't get to 2^512, but this
+ will appropriately tell us whether one loc is closer than
+ another. I also don't get why we want 2^(d/512)!! Say we
+ should be in bucket 5 (5 matching bits), then we get 1
+ as a retrun value, just as if we have 15 matching bits!!!
+ 15 matching should be closer than 5!!!!!!!*/
+ d = exp2 (bucket);
if (d > ((unsigned int) -1))
return -1;
return (unsigned int) d;
@@ -525,6 +534,90 @@
return GNUNET_SYSERR;
}
+void
+printPeerBits (GNUNET_PeerIdentity * peer)
+{
+ unsigned int i;
+ char loc[513];
+ loc[512] = '\0';
+ for (i = 0; i < sizeof (GNUNET_HashCode) * 8; i++)
+ {
+ if (GNUNET_hash_get_bit (&peer->hashPubKey, i) == 0)
+ {
+ loc[i] = '0';
+ }
+ else
+ {
+ loc[i] = '1';
+ }
+ }
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "%s\n", &loc);
+}
+
+void
+printKeyBits (const GNUNET_HashCode * key)
+{
+ unsigned int i;
+ char loc[513];
+ loc[512] = '\0';
+ for (i = 0; i < sizeof (GNUNET_HashCode) * 8; i++)
+ {
+ if (GNUNET_hash_get_bit (key, i) == 0)
+ {
+ loc[i] = '0';
+ }
+ else
+ {
+ loc[i] = '1';
+ }
+ }
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "%s\n", &loc);
+}
+
+/*
+ * Check whether my identity is closer than any known peers.
+ *
+ * Return GNUNET_YES if node location is closest, GNUNET_NO
+ * otherwise.
+ */
+int
+GNUNET_DV_DHT_am_closest_peer (const GNUNET_HashCode * target)
+{
+
+ GNUNET_PeerIdentity closest;
+
+ find_closest_peer (&closest, target);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "closest peer\n");
+ printPeerBits (&closest);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "me\n");
+ printPeerBits (coreAPI->my_identity);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "key\n");
+ printKeyBits (target);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "closest peer inverse distance is %u, mine is %u\n",
+ inverse_distance(target, &closest.hashPubKey),
inverse_distance(target, &coreAPI->my_identity->hashPubKey));
+ if (inverse_distance(target, &coreAPI->my_identity->hashPubKey) >
inverse_distance(target, &closest.hashPubKey))
+ {
+ return GNUNET_YES;
+ }
+ return GNUNET_NO;
+}
+
/**
* Send a discovery message to the other peer.
*
@@ -878,28 +971,6 @@
void
-printPeerBits (GNUNET_PeerIdentity * peer)
-{
- unsigned int i;
- char loc[513];
- loc[512] = '\0';
- for (i = 0; i < sizeof (GNUNET_HashCode) * 8; i++)
- {
- if (GNUNET_hash_get_bit (&peer->hashPubKey, i) == 0)
- {
- loc[i] = '0';
- }
- else
- {
- loc[i] = '1';
- }
- }
- GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
- GNUNET_GE_BULK, "%s\n", &loc);
-}
-
-void
print_buckets ()
{
unsigned int i;
Modified: GNUnet/src/applications/dv_dht/module/table.h
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.h 2009-06-30 22:32:18 UTC
(rev 8610)
+++ GNUnet/src/applications/dv_dht/module/table.h 2009-06-30 22:32:35 UTC
(rev 8611)
@@ -70,4 +70,13 @@
*/
int GNUNET_DV_DHT_table_done (void);
+/*
+ * Check whether my identity is closer than any known peers.
+ *
+ * Return GNUNET_YES if node location is closest, GNUNET_NO
+ * otherwise.
+ */
+int
+GNUNET_DV_DHT_am_closest_peer (const GNUNET_HashCode * target);
+
#endif
Modified: GNUnet/src/applications/dv_dht/tools/dv_test.conf
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_test.conf 2009-06-30 22:32:18 UTC
(rev 8610)
+++ GNUnet/src/applications/dv_dht/tools/dv_test.conf 2009-06-30 22:32:35 UTC
(rev 8611)
@@ -4,10 +4,11 @@
STARTING_PORT=31387
PORT_INCREMENT=2
BASE_CONFIG=gnunetd_dv.conf
-TOPOLOGY=0
+TOPOLOGY=1
+NUM_PEERS=30
#PERCENTAGE=.45
-MYSQL_HOST = localhost
-MYSQL_DB = dhttests
-MYSQL_USER = dht
-MYSQL_PASSWORD = dht**
-
+#MYSQL_SERVER = localhost
+#MYSQL_DB = dhttests
+#MYSQL_USER = dht
+#MYSQL_PASSWORD = dht**
+DOT_OUTPUT=topology.dot
Modified: GNUnet/src/applications/dv_dht/tools/gnunetd_dv.conf
===================================================================
--- GNUnet/src/applications/dv_dht/tools/gnunetd_dv.conf 2009-06-30
22:32:18 UTC (rev 8610)
+++ GNUnet/src/applications/dv_dht/tools/gnunetd_dv.conf 2009-06-30
22:32:35 UTC (rev 8611)
@@ -98,3 +98,10 @@
[TESTING]
WEAKRANDOM = YES
+
+#[MULTIPLE_SERVER_TESTING]
+#MYSQL_SERVER = 130.253.190.125
+#MYSQL_DB = dhttests
+#MYSQL_USER = dht
+#MYSQL_PASSWORD = dht**
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8611 - in GNUnet/src/applications/dv_dht: module tools,
gnunet <=