[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8848 - in GNUnet/src/applications/dv_dht: module tools
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8848 - in GNUnet/src/applications/dv_dht: module tools |
Date: |
Tue, 25 Aug 2009 12:50:39 -0600 |
Author: nevans
Date: 2009-08-25 12:50:39 -0600 (Tue, 25 Aug 2009)
New Revision: 8848
Modified:
GNUnet/src/applications/dv_dht/module/routing.c
GNUnet/src/applications/dv_dht/module/table.c
GNUnet/src/applications/dv_dht/tools/dv_dht_api.c
GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
Log:
cleanup and some minor changes to make sure messages get out
Modified: GNUnet/src/applications/dv_dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/routing.c 2009-08-25 12:16:21 UTC
(rev 8847)
+++ GNUnet/src/applications/dv_dht/module/routing.c 2009-08-25 18:50:39 UTC
(rev 8848)
@@ -88,7 +88,7 @@
* peer will either forward to PUT_TRIES peers that
* are closer to the key, or replicate the content).
*/
-#define PUT_TRIES 3
+#define PUT_TRIES 5
/**
* How long do we keep content after receiving a PUT request for it?
@@ -936,6 +936,10 @@
GNUNET_DV_DHT_estimate_network_diameter ());
if (target_value > GET_TRIES)
target_value = GET_TRIES;
+
+ if ((target_value == 0) && (sender == NULL))
+ target_value = GET_TRIES;
+
j = 0;
if (sender != NULL)
next[j++] = *sender; /* do not send back to sender! */
@@ -966,9 +970,11 @@
DV_DHT_DELAY);
GNUNET_bloomfilter_add (bloom, &next[j].hashPubKey);
-
if (cost == GNUNET_SYSERR)
- continue;
+ {
+ i--;
+ continue;
+ }
GNUNET_bloomfilter_get_raw_data (bloom, &aget.bloomfilter[0],
DV_DHT_BLOOM_SIZE);
@@ -1048,6 +1054,9 @@
store = 0;
target_value = get_forward_count (hop_count, PUT_TRIES);
+ if ((target_value == 0) && (sender == NULL))
+ target_value = PUT_TRIES;
+
aput = GNUNET_malloc (ntohs (msg->size));
memcpy (aput, put, ntohs (msg->size));
aput->hop_count = htonl (hop_count + 1);
@@ -1106,7 +1115,10 @@
#endif
if (cost == GNUNET_SYSERR)
- continue;
+ {
+ i--;
+ continue;
+ }
GNUNET_bloomfilter_get_raw_data (bloom, &aput->bloomfilter[0],
DV_DHT_BLOOM_SIZE);
@@ -1345,6 +1357,7 @@
put->key = *key;
put->type = htonl (type);
put->hop_count = htonl (0);
+ queryuid = 0;
memset (&put->bloomfilter, 0, DV_DHT_BLOOM_SIZE);
put->network_size = htonl (GNUNET_DV_DHT_estimate_network_diameter ());
#if DEBUG_ROUTING
@@ -1411,6 +1424,9 @@
data[l] = rand ();
}
GNUNET_hash (data, 8, &key);
+
+ key.bits[(512 / 8 / sizeof (unsigned int)) - 1] =
+ MAGIC_MALICIOUS_NUMBER;
memset (&data, 0, sizeof (data));
GNUNET_DV_DHT_put (&key, GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
sizeof (data), data);
Modified: GNUnet/src/applications/dv_dht/module/table.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.c 2009-08-25 12:16:21 UTC
(rev 8847)
+++ GNUnet/src/applications/dv_dht/module/table.c 2009-08-25 18:50:39 UTC
(rev 8848)
@@ -679,75 +679,7 @@
return GNUNET_NO;
}
-#ifdef DISCOVERY
/**
- * Send a discovery message to the other peer.
- *
- * @param cls NULL or pre-built discovery message
- */
-static void
-broadcast_dht_discovery (const GNUNET_PeerIdentity * other, void *cls)
-{
- P2P_DV_DHT_Discovery *disco = cls;
- unsigned int pc;
- unsigned int i;
- GNUNET_PeerIdentity *pos;
-#if DEBUG_TABLE
- print_entry ("broadcast_dht_discovery");
-#endif
- if (stats != NULL)
- stats->change (stat_dht_advertisements, 1);
- if (disco != NULL)
- {
- dvapi->dv_send (other,
- &disco->header,
- GNUNET_EXTREME_PRIORITY / 4, 2 * GNUNET_CRON_SECONDS);
-#if DEBUG_TABLE
- print_exit ("broadcast_dht_discovery");
-#endif
- return;
- }
- pc = total_peers;
- if (pc > MAINTAIN_ADV_CAP)
- pc = MAINTAIN_ADV_CAP;
- if (pc == 0)
- pc = 1;
- disco =
- GNUNET_malloc (pc * sizeof (GNUNET_PeerIdentity) +
- sizeof (P2P_DV_DHT_Discovery));
- disco->header.type = htons (GNUNET_P2P_PROTO_DHT_DISCOVERY);
- disco->space_available = -1; /* FIXME */
- pos = (GNUNET_PeerIdentity *) & disco[1];
- i = 0;
- if (total_peers == 0)
- {
- /* put in our own identity (otherwise we get into a
- storm of empty discovery messages) */
- pos[0] = *coreAPI->my_identity;
- i = 1;
- }
- while (i < pc)
- {
- if (GNUNET_OK !=
- GNUNET_DV_DHT_select_peer (&pos[i], &other->hashPubKey, pos, i))
- pc--;
- else
- i++;
- }
- disco->header.size =
- htons (pc * sizeof (GNUNET_PeerIdentity) + sizeof (P2P_DV_DHT_Discovery));
- //fprintf(stderr, "Sending discovery message, number of known peers %d\n",
total_peers);
- dvapi->dv_send (other, &disco->header, GNUNET_EXTREME_PRIORITY / 4,
- 2 * GNUNET_CRON_SECONDS);
- GNUNET_free (disco);
-#if DEBUG_TABLE
- print_exit ("broadcast_dht_discovery");
-#endif
-}
-#endif
-
-
-/**
* We have received a pong from a peer and know it is still
* there.
*/
Modified: GNUnet/src/applications/dv_dht/tools/dv_dht_api.c
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_dht_api.c 2009-08-25 12:16:21 UTC
(rev 8847)
+++ GNUnet/src/applications/dv_dht/tools/dv_dht_api.c 2009-08-25 18:50:39 UTC
(rev 8848)
@@ -318,7 +318,11 @@
memcpy (&req[1], value, size);
ret = GNUNET_client_connection_write (sock, &req->header);
if (ret != GNUNET_OK)
- return ret;
+ {
+ GNUNET_client_connection_destroy (sock);
+ GNUNET_free (req);
+ return ret;
+ }
if ((GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret2)) ||
(ret2 != GNUNET_OK))
ret = GNUNET_SYSERR;
Modified: GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c 2009-08-25
12:16:21 UTC (rev 8847)
+++ GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c 2009-08-25
18:50:39 UTC (rev 8848)
@@ -34,7 +34,7 @@
#include "gnunet_remote_lib.h"
#include "gnunet_dhtlog_service.h"
-#define MAX_THREADS 100
+#define DEFAULT_MAX_THREADS 100
struct GNUNET_DV_DHT_keys
{
@@ -62,8 +62,11 @@
static unsigned long long malicious_putters;
static unsigned long long malicious_getters;
static unsigned long long malicious_droppers;
+static unsigned long long totalBytesDropped;
+static unsigned long long totalMessagesDropped;
static int randomized_gets;
+static int max_threads;
static double malicious_putter_num;
static double malicious_getter_num;
@@ -154,6 +157,19 @@
{
fprintf (stderr, "%s : %llu\n", name, value);
}
+ else if ((value > 0)
+ && (strstr (name, _("# outgoing messages dropped")) != NULL))
+ {
+ totalMessagesDropped += value;
+ fprintf (stderr, "%s : %llu\n", name, value);
+ }
+ else if ((value > 0)
+ && (strstr (name, _("# bytes of outgoing messages dropped")) !=
+ NULL))
+ {
+ totalBytesDropped += value;
+ fprintf (stderr, "%s : %llu\n", name, value);
+ }
else if ((value > 0) && (strstr (name, _("dropped")) != NULL))
{
fprintf (stderr, "%s : %llu\n", name, value);
@@ -169,8 +185,8 @@
{
struct GNUNET_REMOTE_TESTING_DaemonContext *peers;
struct GNUNET_REMOTE_TESTING_DaemonContext *peer_array[num_peers];
- struct GNUNET_DV_DHT_Context *dctx[MAX_THREADS];
- struct GNUNET_DV_DHT_GetRequest *gets[MAX_THREADS];
+ struct GNUNET_DV_DHT_Context *dctx[max_threads];
+ struct GNUNET_DV_DHT_GetRequest *gets[max_threads];
struct GNUNET_DV_DHT_keys keys[put_items];
struct GNUNET_REMOTE_TESTING_DaemonContext *pos;
int ret = 0;
@@ -185,7 +201,7 @@
int key_count;
- int random_peers[MAX_THREADS];
+ int random_peers[max_threads];
int random_peer;
int random_key;
int totalConnections;
@@ -391,7 +407,7 @@
printf ("Found %u out of %llu attempts.\n", new_found,
concurrent_requests);
- if (thread_count >= MAX_THREADS)
+ if (thread_count >= max_threads)
{
for (j = 0; j < thread_count; j++)
{
@@ -440,7 +456,8 @@
pos = pos->next;
}
- ret = sqlapi->update_trial (trialuid);
+ ret =
+ sqlapi->update_trial (trialuid, totalMessagesDropped, totalBytesDropped);
return ret;
}
@@ -463,6 +480,7 @@
GNUNET_init (argc, argv, "dvdhtdriver", &configFile,
gnunetDHTDriverOptions, &ectx, &driverConfig);
+ max_threads = DEFAULT_MAX_THREADS;
if (ret == -1)
{
GNUNET_fini (ectx, cfg);
@@ -552,6 +570,11 @@
if (malicious_droppers > 0)
malicious_dropper_num = num_peers / malicious_droppers;
+ while (max_threads % concurrent_requests != 0)
+ {
+ max_threads++;
+ }
+
memset (&capi, 0, sizeof (GNUNET_CoreAPIForPlugins));
capi.cfg = cfg;
capi.service_request = &rs;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8848 - in GNUnet/src/applications/dv_dht: module tools,
gnunet <=